New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here


by: Mr. Molly Kessler


Mr. Molly Kessler
GPA 3.62


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 40 page Class Notes was uploaded by Mr. Molly Kessler on Tuesday October 13, 2015. The Class Notes belongs to CSC 4103 at Louisiana State University taught by Staff in Fall. Since its upload, it has received 15 views. For similar materials see /class/222870/csc-4103-louisiana-state-university in ComputerScienence at Louisiana State University.




Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/13/15
Process Management l OS becomes more complex in going from a Single to multiprogramming system 4 Single user to timesharing system I A collection of processes executing user or OS codes exist a OS is responsible for all process management activities I Topics to be covered it Processes 4 Threads CPU Scheduling Process Synchronization 44gt Deadlocks 080 4108 Operating System 31 BB Karki LSU Processes Source Operating System Concepts by Silberschatz Galvin and Gagne 080 4108 Operating System 82 BB Karki LSU Outline VI Process Concept l Process Scheduling l Operations on Processes Interprocess Communication l Communication in ClientServer Systems 080 4108 Operating System as BB Karki LSU Process Concept l A computer system executes a variety of programs Y an 08 programs system calls 4 Batch system jobs r Time shared systems user programs or tasks 4 Singleuser systems different application programs I All these CPU activities are processes I Textbook uses the terms job and process almost interchangeably 080 4108 Operating System 34 BB Karki LSU What Is Process l Process a program in execution is an active entity a program is passive stack V entity until it is in execution is a unit of CPU work 1 executes OS and user codes requires certain resources to do its task supports a single or multiple threads T 4 9 heap l A process Includes 0 Program counter and processor s registers data defining current activity 0 Stack heap data and text text 080 4103 Operating System 35 BB Karki LSU Process State I As a process executes it changes state new The process is being created running Instructions are being executed waiting The process is waiting for some event to occur eg lO completion as 9 d ready The process is waiting to be assigned to a processor terminated The process has finished execution d admitted interrupt exit terminated IO or event completion SChedUler dISPatCh lO or event wait waiting I Only one process can be running on any processor at any instant although many processes may be ready and waiting 080 4103 Operating System 36 BB Karki LSU Process Control Block PCB Information associated with each process is represented by PCB Also called TCB Process state 1 New ready running waiting and terminated Process number s pid Program counter a Indicates the address of the next instruction to be executed for this process CPU registers 0 Accumulators registers stack pointers CPU scheduling information 139 Process priority scheduling queue pointers Memorymanagement information as Values of base and limit registers page tables etc Accounting information is CPU or real time used time limits account numbers process numbers O status information a List of HO devices list of files 080 4103 Operating System 37 process state process number program counter registers memory limits list of open files BB Karki LSU CPU Switch From Process to Process l PCB serves as the repository for any information that may vary from process to process I The state information must be saved when an interrupt occurs to allow the process to be continued correctly afterward 080 4103 Operating System process P0 executing gtide executing operating system interrupt or system call save state into PCB0 reload state from PCB1 interrupt or system call V 7 save state into P031 reload state from Pi JBO process P1 idle executing idle BB Karki LSU Process Scheduling I If more than one processes exist the rest must wait until the CPU is freed by the running process and can be available The scheduling is required in w Multiprogramming to have some process running at all times 1 Timesharing to switch the CPU among processes specified by users I Scheduling Queues 7 Job queue set of all processes in the system Ready queue set Of lO queue H lO request all processes residing in main memory ready and waiting to execute Device queue set of processes waiting for an O device Process migration between the various q ueues 080 4103 Operating System 39 BB Karki LSU 3 time slice expired v quot9 wait for an interrupt interrupt occurs Ready Queue And Various V0 Device Queues l Linked list A queue header contains pointers to the first and final PCBs in the list Each PCB is extended to include a pointer field that points to the next PCB in the queue 080 4108 Operating System queue header PCB7 PCB2 registers registers nag ape nag ape PCB PCB PCB unit1 3 4 6 disk head unitO ta PCB5 erminal l head l 39 unItO ta l 310 BB Karki LSU Schedulers l 08 must select processes for scheduling purposes in some fashion carried out by an appropriate scheduler l Two types of schedulers ow Shortterm scheduler or CPU scheduler selects which process should be executed next and allocates CPU J Deals with programs which are already brought to memory it Longterm scheduler or job scheduler selects which processes should be brought into the ready queue l Major difference in the frequency of execution at Shortterm scheduler is invoked very frequently milliseconds gt must be fast Longterm scheduler is invoked very infrequently seconds minutes gt may be slow 080 4108 Operating System 311 BB Karki LSU Schedulers Contd l The longterm scheduler controls the degree of multiprogramming ie the number of processes in memory I Processes can be described as either Obound process spends more time doing O than computation many short CPU bursts CPUbound process spends more time doing computation few very long CPU bursts A balanced combination of two types for a better performance 080 4108 Operating System 312 BB Karki LSU Addition of Medium Term Scheduling swap in partially executed swapped out processes swap out lO waiting queues Mediumterm scheduler also called swapping swaps processes out of memory and later swaps them into the memory It thus reduces the degree of multiprogramming 080 4108 Operating System BB Karki LSU Context Switch I When CPU switches to another process the system must save v the state of the old process and load the saved state for the new process This task is known as a context switch at The context of a process is represented by PCB l Contextswitch time is overhead the system does no useful work while switching I This time is dependent on hardware support 4 Switching speed depends on memory speed number of registers that must be copied and special instructions such as single instruction to load or store all registers 1 Typical speeds range from 1 to 1000 us as Switching time may be bottleneck for complex OS 080 4108 Operating System 314 BB Karki LSU Operations on Processes l Processes can execute concurrently may be created and deleted dynamically l Mechanisms for process creation and termination 080 4108 Operating System 815 BB Karki LSU Process Creation l Parent process can create children processes which in turn create other processes forming a tree of processes I Resource sharing a Parent and children share all resources at Children share subset of parent s resources a Parent and child share no resources I Initialization data Passed along from parent to child process I Execution 4quot Parent and children execute concurrently Parent waits until children terminates 080 4108 Operating System 316 BB Karki LSU Process Creation l Parent process creates children processes which in turn create other processes forming a tree of processes Atree of processes on a typical Solaris system inetd pid 140 telnetdaemon pid 7776 dtlogin pid 251 Xsession pid 294 sdtishel pid 340 Netscape pid 7735 emacs pid 8105 pageout pid 2 fs ush pid 3 Process Creation Cont l Address space 4 Child duplicate of parent a Child has a program loaded into it I Forking a process a fork system call creates new process 4 execlp system call replaces the process memory space with a new program the Unix command lbinls in this example parent wait resumes 030 4103 Operating System 3 18 EB Karkl LSU C Program Forking a Separate Process int pid pid fork i if pid 0 execlp binls ls NULL else if pid gt 0 wait NULL printf quotChild Completequot exit 0 080 4108 Operating System 319 BB Karki LSU Process Termination l Normal Process executes its final statement and ask the OS to delete it exit Output data from child to parent via wait a Process resources are deallocated by the OS I Abnormal Parent may terminate execution of children processes abort 77 Child has exceeded allocated resources a Task assigned to child is no longer required at Parent is exiting J 08 does not allow child to continue if its parent terminates J Cascading termination All children terminated 080 4108 Operating System 320 BB Karki LSU Interprocess Communication IPC l Independent processes cannot affect or be affected by the execution of another process 6 Such processes do not share any data I Cooperating processes can affect or be affected by the execution of another process It Such processes share data Interpocess communication IPC mechanisms allow such processes to exchange data and information 4 Such processes need to be synchronized l Advantages of process cooperation Information sharing it Computation speedup 4 Modularity r Convenience 080 4108 Operating System 321 BB Karki LSU Communication Models l Two IPC mechanisms Message passing Useful for exchanging smaller amounts of data Easier to implement through system calls but slower 1 Shared memory Allows maximum speed and convenience of communication Faster accesses to shared memory process A process A shared 3 2 process B process 8 H kernel 7 kernel BB Karki LSU b 050 4103 Operating a ProducerConsumer Problem l Sharedmemory systems Communicating processes establish a region of shared memory They can exchange information by reading and writing data in the shared areas I Paradigm for cooperating processes producer process produces information that is consumed by a consumer process 4 eg a print program produces characters that are consumed by the printer driver I A buffer of items that can be filled by the producer and emptied by the consumer This buffer will reside in a region of memory that is shared by both processes t unboundedbuffer places no practical limit on the size of the buffer are boundedbuffer assumes a fixed buffer size 080 4108 Operating System 323 BB Karki LSU BoundedBuffer SharedMemory Solution I How cooperating processes share a common buffer pool 7 Shared variables define BUFFERSIZE 10 Typedef struct item item bufferBUFFERSIZE int in 0 int out 0 7 The shared buffer is implemented as a circular array with two logical pointers in and out 080 4108 Operating System 324 BB Karki LSU BoundedBuffer Producer Process l The producer process has a local variable nextProduced in which the new item to be produced is stored while 1 while in 1 BUFFERSIZE out do nothing bufferin nextProduced in in l BUFFERSIZE 080 4108 Operating System 325 BB Karki LSU BoundedBuffer Consumer Process l The consumer process has a local variable nextConsumed in which the item to be consumed is stored while 1 while in out do nothing nextConsumed bufferout out out 1 BUFFERSIZE 080 4108 Operating System BB Karki LSU MessagePassing Systems A mechanism for cooperating processes to communicate and to synchronize their actions without sharing the same address space via a messagepassing facility is Useful in a distributed environment Messagepassing facility provides two operations sendmessage message size fixed or variable receivemessage If P and 0 wish to communicate they need to a establish a communication link between them at exchange messages via sendreceive Implementation of communication link at physical eg shared memory hardware bus or network or logical 080 4108 Operating System 327 BB Karki LSU Implementation Questions I How are links established I Can a link be associated with more than two processes I How many links can there be between every pair of communicating processes I What is the capacity of a link I Is the size of a message that the link can accommodate fixed or variable I Is a link unidirectional or bidirectional 080 4108 Operating System 328 BB Karki LSU Direct Communication l Processes in communication must name each other explicitly send P message send a message to process P receiveQ message receive a message from process Q l Properties of communication link k Links are established automatically A link is associated with exactly one pair of processes r Exactly one link exists between each pair of processes it The link exhibits symmetry in addressing l Asymmetry in addressing Only sender names the recipient the recipient is not required to name the sender send P message send a message to process P receiveid message receive a message from any process id l Disadvantage A limited modularity of the resulting process definitions 080 4108 Operating System 329 BB Karki LSU Indirect Communication l Messages are sent to and received from mailboxes or ports 4 Each mailbox has a unique id 72quot Processes can communicate only if they share a mailbox sendA message send a message to mailbox A receiveA message receive a message from mailbox A l Properties of communication link Link is established only if processes share a common mailbox fir A link may be associated with many processes more than two a Each pair of processes may share several communication links as Link may be unidirectional or bidirectional l A mailbox may be owned by a particular process or the 08 Only owner process can receive message through the mailbox l 08 mechanism for a process to do the following 72gt create a new mailbox 39 send and receive messages through mailbox 4 destroy a mailbox 080 4108 Operating System 330 BB Karki LSU Synchronization l Message passing may be either blocking or nonblocking also known as synchronous and asynchronous l Blocking send The sending process is blocked until the message is received by the receiving process or by the mailbox l Nonblocking send The sending process sends the message and resumes operation I Blocking receive The receiver blocks until the message is available I Nonblocking receive The receiver retrieves either a valid message or a null l Different combinations of send and receive are possible 080 4108 Operating System 331 BB Karki LSU Bu e ng l Messages exchanged by processes reside in a temporary queue during communication l The queue is implemented in one of three ways a Zero capacity No messages in the queue Sender must block until the receiver receives the message a Bounded capacity Finite length of n messages Sender must block if link full and until space is available in queue Unbounded capacity Infinite length Sender never blocks Any number of messages can be put in the queue 080 4108 Operating System 332 BB Karki LSU ClientServer Communication I To have access to data located at some server 4 Sockets 4 Remote Procedure Calls 4 Remote Method Invocation Java 080 4108 Operating System 333 BB Karki LSU Sockets l A socket is defined as an endpoint for communication A pair of processes communicating over a network employs a pair of sockets one for each process I Each socket is made up of an IP address concatenated with a port number at The socket 161251981625 refers to port 1625 on host 16125198 l Port numbers below 1024 are considered for standard services such as telnet 23 ftp 21 and http 80 I When a client process initiates a request for a connection it is assigned a port by the host computer with port number gt 1024 i All connections must be unique with each process having a different port number 080 4108 Operating System 334 BB Karki LSU Socket Communication host X 14686520 socket 146865201625 web server 165125198 socket 161 2519880 050 4103 Operating System 335 BB Karki LSU Remote Procedure Calls l Remote procedure call RPC abstracts procedure calls between processes on networked systems I Stubs clientside proxy for the actual procedure on the server I The clientside stub locates the server and marshals the parameters l The serverside stub receives this message unpacks the marshalled parameters and peforms the procedure on the server 080 4108 Operating System 336 BB Karki LSU Execution of RFC maKchmaker me enem daemon To39 server listening 10 Pan port P pan P receives ltcontemsgt sage ParCF Ta39 euem eme 0504108 Operaung System lt PU gt BB Kern LSU Remote Method Invocation l Remote Method Invocation RMI is a Java mechanism similar to RPCs l RMI allows a Java program on one machine to invoke a method on a remote object JVM remote object 080 4103 Operating System 338 BB Karki LSU Marshalling Parameters Client remote object val serversomeMethodAB stub boolean someMethod Object x Object y implementation of someMethod skeleton A B someMethod boolean return value CSCMLB Operatlng System BB Karkl LSU Summary A process is a program in execution 9 It changes state as it executes it Each process is represented by its own PCB i Processes can be created and terminated dynamically Process scheduling i Scheduling queues ready and HG queues 4e Longterm job and short term CPU schedulers Processes can execute concurrently i Information sharing computation speed up modularity and convenience Cooperating processes need to communicate each other using two IPC models 2 Shared memory by sharing some variables 3 Message systems by exchanging messages Communication as Using sockets one at each end of the communication channel 6 BPC a process calls a procedure on a remote application iv BMI Java version of BPC invoking a method on a remote object 080 4108 Operating System 340 BB Karki LSU


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Amaris Trozzo George Washington University

"I made $350 in just two days after posting my first study guide."

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.