SlideShare a Scribd company logo
1 of 26
Download to read offline
Processes


1.   Process Concept
2.   Process Scheduling
3.   Operations on Processes
4.   Interprocess Communication
1. Process Concept
• An operating system executes a variety of
  programs:
  – Batch system – jobs
  – Time-shared systems – user programs or tasks
• The terms job and process are used almost
  interchangeably
• 1.1 The Process
  – a program in execution; process execution must
    progress in sequential fashion
  – A process includes:
     • program counter - current activity
     • Stack - temporary data(function, parameters, return
       addresses, and local variables)
     • data section - global variables
     • heap - dynamically allocated memory during process run
       time
                     Loganathan R, CSE, HKBKCE             2
1. Process Concept Contd…
 Process in Memory
                                • A program by itself is not a
                                  process
                                • A program is a passive
                                  entity, a file containing a list
                                  of instructions stored on
                                  disk (often called an
                                  executable file)
                                • A process is an active entity,
                                  with a program counter
                                  specifying       the      next
                                  instruction to execute and a
                                  set of associated resources
                     Loganathan R, CSE, HKBKCE                  3
1. Process Concept Contd…
1.2 Process State
• As a process executes, it changes state, state of a process is defined
   in part by the current activity of that process
    – new: The process is being created
    – running: Instructions are being executed
    – waiting: The process is waiting for some event to occur
    – ready: The process is waiting to be assigned to a processor
    – terminated: The process has finished execution




                          Loganathan R, CSE, HKBKCE                4
1. Process Concept Contd…
1.3 Process Control Block (PCB) also called task control block contains
     information associated with each process
•    Process state - new, ready, running, waiting, halted
•    Program counter - the address of the next instruction to be executed
•    CPU registers - accumulators, index registers, stack pointers, and general-
     purpose registers
•    CPU scheduling information - process priority, pointers to scheduling queues
     and scheduling parameters
•    Memory-management information - value of the base and limit registers,
     the page tables, or the segment tables
•    Accounting information - the amount of CPU and real time used, time limits,
     account numbers, job or process numbers
•    I/O status information - list of I/O devices allocated to the process, a list of
     open files
1.4 Threads
• A process is a program that performs a single thread of execution
• Single thread of control allows the process to perform only one task at one
  time
• Multiple threads of execution perform more than one task at a time
                                Loganathan R, CSE, HKBKCE                         5
1. Process Concept Contd…
Process Control   CPU Switch From Process to Process
Block (PCB)




                  Loganathan R, CSE, HKBKCE            6
2. Process Scheduling
• Multiprogramming and Time Sharing switch the
  CPU among processes so frequently that users can
  interact with each program
• Process Scheduler selects an available process
  (possibly from a set of several available processes)
  for program execution on the CPU
2.1 Scheduling Queues
• Job queue – set of all processes in the system
• Ready queue – set of all processes residing in
  main memory, ready and waiting to execute
• Device queues – set of processes waiting for an
  I/O device. Each device has its own device queue
• Processes migrate among the various queues
                   Loganathan R, CSE, HKBKCE        7
2. Process Scheduling Contd…
Ready Queue And Various I/O Device Queues




                      Loganathan R, CSE, HKBKCE   8
2. Process Scheduling Contd…
• Representation of Process Scheduling is Queuing Diagram
• Rectangle represents a queue, Circle represent the resource and arrow indicate the flow
  of processes
• New process is initially put in the ready queue and waits there until it is selected for
  execution, or is dispatched
• Once the process is allocated the CPU and is executing, the events may occur are:
 The process could issue an I/O request and then be placed in an I/O queue
 The process could create a new sub process and wait for the sub process's Termination
 The process could be removed forcibly from the CPU, as a result of an interrupt, and be
   put back in the ready queue




                                 Loganathan R, CSE, HKBKCE                             9
2. Process Scheduling Contd…
2.2 Schedulers
• The selection processes from those queue is carried out by the
  appropriate scheduler
• Long-term scheduler (or job scheduler) – selects which processes should
  be brought into the ready queue
  Executes much less frequently, minutes may separate the creation of one
   new process and the next
  controls the degree of multiprogramming (the number of processes in
   memory)
  take more time to decide which process should be selected for execution
  select a good process mix of I/O-bound(spends more of its time doing I/O)
   and CPU-bound (spends more of its time doing computations) processes)
  Time-sharing systems (UNIX &Windows) have no long-term scheduler but
   simply put every new process in memory for the short-term scheduler
• Short-term scheduler (or CPU scheduler) – selects which process should
  be executed next and allocates CPU
  select a new process for the CPU frequently i.e. executes at least once every
   100 milliseconds
  Must be fast. i.e. If it takes 10 milliseconds to decide to execute a process for
   100 milliseconds, then 10/(100 + 10) = 9 percent of the CPU is being wasted
   simply for scheduling the work Loganathan R, CSE, HKBKCE                       10
2. Process Scheduling Contd…
Medium Term Scheduler
• Intermediate level of scheduling, removes processes from memory (and
  from active contention for the CPU) to reduce the degree of
  multiprogramming
• The process can be reintroduced later into memory, and its execution
  can be continued where it left off(Swapping)




                         Loganathan R, CSE, HKBKCE                 11
2. Process Scheduling Contd…
2.3 Context Switch
• When CPU switches to another process, the
  system must save the state(PCB) of the old
  process and load the saved state for the new
  process is known as context switch
• Context-switch time is overhead; the system
  does no useful work while switching
• Time dependent on hardware support
  – Sun UltraSPARC provide multiple sets of registers,
    which requires changing the pointer to the current
    register set

                   Loganathan R, CSE, HKBKCE       12
3. Operations on Processes
3.1 Process Creation
• Parent process create children processes via create-process
  systemcall, which, in turn create other processes, forming a tree of
  processes
• Processes are identified according to a unique process identifier(or
  pid), which is typically an integer number




                                                      A tree of process on a
                                                      Solaris system

                          Loganathan R, CSE, HKBKCE                        13
3. Operations on Processes Contd…
• When a Process creates new process,
• Resource sharing
  • Parent and children share all resources
  • Children share subset of parent’s resources
  • Parent and child share no resources
• Execution possibilities
  • Parent and children execute concurrently
  • Parent waits until children terminate
 • Address space possibilities
  • Child duplicate of parent
  • Child has a program loaded into it
                   Loganathan R, CSE, HKBKCE      14
3. Operations on Processes Contd…
Process Creation UNIX examples
 • fork system call creates new process
 • exec system call used after a fork to replace the process’s memory
   space with a new program            int main()
                                           {
                                           pid_t pid;
                                               pid = fork();
                                               if (pid < 0) { /* error occurred */
                                                       fprintf(stderr, "Fork Failed");
                                                       exit(-1);
                                               }
                                               else if (pid == 0) { /* child process */
                                                       execlp("/bin/ls", "ls", NULL);
                                               }
                                               else { /* parent process */
                                               /* parent wait for the child to complete */
                                                       wait (NULL);
                                                       printf ("Child Complete");
        Process Creation                               exit(0);
                                               }
                                           }
                                               C Program Forking Separate Process
                           Loganathan R, CSE, HKBKCE                                15
3. Operations on Processes Contd…
3.2 Process Termination
• Process executes last statement and asks the
  operating system to delete it (using exit())
  – Output data from child to parent (via wait())
  – Process’s resources are deallocated by operating
    system
• Parent may terminate execution of children
  processes (abort)
  – Child has exceeded allocated resources
  – Task assigned to child is no longer required
  – If parent is exiting
     • Some operating system do not allow child to continue if its
       parent terminates
         – All children terminated - cascading termination

                         Loganathan R, CSE, HKBKCE                   16
4. Interprocess Communication
• Processes executing concurrently in the operating system may be
  either independent processes or cooperating processes
• Independent process cannot affect or be affected by the
  execution of another process
• Cooperating process can affect or be affected by the execution of
  another process
• Advantages of process cooperation
 • Information sharing
 • Computation speed-up – break into subtasks, each of which will be
   executing in parallel
 • Modularity - dividing the system functions into separate processes or
   threads
 • Convenience - individual user may work on many tasks at the same
   time
• Cooperating processes require an interprocess communication
  (IPC) mechanism to exchange data and information
                          Loganathan R, CSE, HKBKCE                 17
4. Interprocess Communication Contd…
• Two fundamental models of Interprocess communication
• Shared memory
 • a region of memory that is shared by cooperating processes is established then
   exchange information takes place by reading and writing data to the shared region
• Message passing
 • communication takes place by means of messages exchanged between the
   cooperating processes
   Message passing




                                                                            Shared memory
                               Loganathan R, CSE, HKBKCE                                    18
4. Interprocess Communication Contd…
4.1 Shared memory Systems
• A shared-memory region resides in the address space of the process
  creating the shared-memory
• Other processes that wish to communicate using this shared-memory
  segment must attach it to their address space
• The form of the data and the location are determined by these
  processes and are not under the operating system's control
• Example : Producer-Consumer Problem - Paradigm for cooperating
  processes, producer process produces information that is consumed by
  a consumer process
 • Example : compiler may produce assembly code, which is consumed by an
   assembler, in turn, may produce object modules, which are consumed by the
   loader
• To allow producer and consumer processes to run concurrently, we
  must have available a buffer of items that can be filled by the producer
  and emptied by the consumer
 • unbounded-buffer places no practical limit on the size of the buffer (customer
   may wait)
 • bounded-buffer assumes that there is a fixed buffer size(both waits)
                              Loganathan R, CSE, HKBKCE                      19
4. Interprocess Communication Contd…
Bounded-Buffer – Shared-Memory Solution
• Shared buffer is implemented as a circular array
  with two logical pointers: in and out
• The buffer is empty when in == out; the buffer is
  full when ((in + 1) % BUFFER_SIZE) == out.
        #define BUFFER_SIZE 10
        typedef struct {
           ...
        } item;

        item buffer[BUFFER_SIZE];
        int in = 0;
        int out = 0;


                        Loganathan R, CSE, HKBKCE   20
4. Interprocess Communication Contd…
Code for the producer and consumer processes
• Producer process
         item nextProduced;
         while (true) {
            /* produce an item in nextProduced */
            while ( ( ( in + 1) % BUFFER-SIZE) == out)
            ; /* do nothing */
            buffer[in] = nextProduced;
            in = (in + 1) % BUFFER_SIZE;
         }
• Consumer process
         item nextConsumed;
         while (true) {
            while (in == out)
            ; //do nothing
            nextConsumed = buffer[out];
            out = (out + 1) % BUFFEFLSIZE;
            /* consume the item in nextConsumed */
         }
                      Loganathan R, CSE, HKBKCE          21
4. Interprocess Communication Contd…
4.2 Message-Passing Systems
• Mechanism for processes to communicate and to
  synchronize their actions
• Message system – processes communicate with each
  other without resorting to shared variables
• IPC facility provides two operations:
   – send(message) – message size fixed or variable
   – receive(message)
• If ProcessP and Q wish to communicate, they need to:
   – establish a communication link(Not Phsical) between them
   – exchange messages via send/receive
• Implementation of communication link
   – physical (e.g., shared memory, hardware bus or network)
   – logical (e.g., logical properties)
                        Loganathan R, CSE, HKBKCE               22
4. Interprocess Communication Contd…
• Methods for logically implementing a link and send() / receive () operations
   • Direct or indirect communication
   • Synchronous or asynchronous communication
   • Automatic or explicit buffering
4.2.1 Naming - Processes must name each other explicitly in Direct
  Communication
   • send (P, message) – send a message to process P
   • receive(Q, message) – receive a message from process Q
• Properties of communication link
   • Links are established automatically
   • A link is associated with exactly one pair of communicating processes
   • Between each pair there exists exactly one link
   • The link may be unidirectional, but is usually bi-directional
• In Symmetry addressing - both the sender process and the receiver process
   must name the other i.e. send(P, message) and receive (Q, message)
• In asymmetry addressing - only the sender names the recipient
   • send(P, message)—Send a message to process P
   • receive(id, message)—-Receive a message from any process; id will be the
      name of the sender process (disadvantage – Changing id of a process
    necessitates all references to the old id)     Loganathan R, CSE, HKBKCE
                                                                               23
4. Interprocess Communication Contd…
• Messages are sent to and received from mailboxes or ports
  • Each mailbox has a unique id
  • Processes can communicate only if they share a mailbox
  • Primitives : send(A, message and receive(A, message) where A is a mailbox
• Properties of communication link
  •   Link established only if processes share a common mailbox
  •   A link may be associated with more than two processes
  •   Each pair of processes may share several communication links
  •   Link may be unidirectional or bi-directional
• Mailbox sharing
  • P1, P2, and P3 share mailbox A and P1, sends to A; Who gets the message?
  • Allow a link to be associated with at most two processes
  • Allow only one process at a time to execute a receive operation
  • Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.
    The system may define an algorithm(RR) for selection
  • A mailbox may be owned either by a process or the OS
  • If the mailbox is owned by a process, it is distinguished as owner (only receive) & user (only send)
  • A mailbox owned by OS has an existence of its own and allows a process to
     – create a mailbox , send and receive messages through mailbox and destroy a mailbox
 • The process that creates a new mailbox is the owner and it can only receive messages,
    ownership and receiving privilege may be passed to other processes through appropriate
    system calls
                                       Loganathan R, CSE, HKBKCE                                    24
4. Interprocess Communication Contd…
4.2.2 Synchronization
• Different design options for implementing send() and
  receive () primitives
• Message passing may be either blocking or non-blocking
  also known as synchronous or asynchronous.
• Blocking is considered synchronous
   – Blocking send - sender block until the message is received
   – Blocking receive - receiver block until a message is available
   – rendezvous between the sender and the receiver
• Non-blocking is considered asynchronous
   – Non-blocking send - sender send the message and continue
   – Non-blocking receive - receiver receive a valid message or
     null

                        Loganathan R, CSE, HKBKCE                25
4. Interprocess Communication Contd…
4.2.3 Buffering
• Messages exchanged by communicating processes
  reside in a temporary queue
• Queue of messages attached to the link is implemented
  in one of three ways
   – Zero capacity – The queue length is zero, no messages can
     wait. Sender must wait for receiver (rendezvous)
   – Bounded capacity – finite length of n messages. Sender must
     wait if link full
   – Unbounded capacity – infinite length Sender never waits




                       Loganathan R, CSE, HKBKCE              26

More Related Content

What's hot

OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Conceptssgpraju
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Kernel. Operating System
Kernel. Operating SystemKernel. Operating System
Kernel. Operating Systempratikkadam78
 
Inter process communication
Inter process communicationInter process communication
Inter process communicationMohd Tousif
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Shivam Mitra
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Beneath the Linux Interrupt handling
Beneath the Linux Interrupt handlingBeneath the Linux Interrupt handling
Beneath the Linux Interrupt handlingBhoomil Chavda
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitorssgpraju
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process managementArnav Chowdhury
 
Operating Systems: Virtual Memory
Operating Systems: Virtual MemoryOperating Systems: Virtual Memory
Operating Systems: Virtual MemoryDamian T. Gordon
 

What's hot (20)

OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
 
Chapter 3 - Processes
Chapter 3 - ProcessesChapter 3 - Processes
Chapter 3 - Processes
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Kernel. Operating System
Kernel. Operating SystemKernel. Operating System
Kernel. Operating System
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Beneath the Linux Interrupt handling
Beneath the Linux Interrupt handlingBeneath the Linux Interrupt handling
Beneath the Linux Interrupt handling
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Os unit 3 , process management
Os unit 3 , process managementOs unit 3 , process management
Os unit 3 , process management
 
Operating Systems: Virtual Memory
Operating Systems: Virtual MemoryOperating Systems: Virtual Memory
Operating Systems: Virtual Memory
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Process threads operating system.
Process threads operating system.Process threads operating system.
Process threads operating system.
 

Viewers also liked

Op Sy 03 Ch 23
Op Sy 03 Ch 23Op Sy 03 Ch 23
Op Sy 03 Ch 23 Google
 
Code4vn linux day1 operating system concept
Code4vn linux day1 operating system conceptCode4vn linux day1 operating system concept
Code4vn linux day1 operating system conceptCường Nguyễn
 
9 virtual memory management
9 virtual memory management9 virtual memory management
9 virtual memory managementDr. Loganathan R
 
Processes Control Block (Operating System)
Processes Control Block (Operating System)Processes Control Block (Operating System)
Processes Control Block (Operating System)Imdad Ullah
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategiesDr. Loganathan R
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess CommunicationDeepak H L
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communicationSushil Singh
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
Insider operating system
Insider   operating systemInsider   operating system
Insider operating systemAditi Saxena
 
Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04Cahyo Darujati
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock GalvinSonali Chauhan
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 

Viewers also liked (20)

Op Sy 03 Ch 23
Op Sy 03 Ch 23Op Sy 03 Ch 23
Op Sy 03 Ch 23
 
Code4vn linux day1 operating system concept
Code4vn linux day1 operating system conceptCode4vn linux day1 operating system concept
Code4vn linux day1 operating system concept
 
9 virtual memory management
9 virtual memory management9 virtual memory management
9 virtual memory management
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Processes Control Block (Operating System)
Processes Control Block (Operating System)Processes Control Block (Operating System)
Processes Control Block (Operating System)
 
8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Chapter9
Chapter9Chapter9
Chapter9
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess Communication
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communication
 
Ipc ppt
Ipc pptIpc ppt
Ipc ppt
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
7 Deadlocks
7 Deadlocks7 Deadlocks
7 Deadlocks
 
4 threads
4 threads4 threads
4 threads
 
10 File System
10 File System10 File System
10 File System
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Insider operating system
Insider   operating systemInsider   operating system
Insider operating system
 
Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
IPC
IPCIPC
IPC
 

Similar to 3 process management

Process Management.pdf
Process Management.pdfProcess Management.pdf
Process Management.pdfYashjangid9
 
Operating System 3
Operating System 3Operating System 3
Operating System 3tech2click
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringYogesh Santhan
 
Operating system 18 process creation and termination
Operating system 18 process creation and terminationOperating system 18 process creation and termination
Operating system 18 process creation and terminationVaibhav Khanna
 
Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesHelpWithAssignment.com
 
UNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdfUNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdfaakritii765
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementVeejeya Kumbhar
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptMohammad Almuiet
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 

Similar to 3 process management (20)

Process Management.pdf
Process Management.pdfProcess Management.pdf
Process Management.pdf
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Ch3 processes
Ch3   processesCh3   processes
Ch3 processes
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - Engineering
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
Operating system 18 process creation and termination
Operating system 18 process creation and terminationOperating system 18 process creation and termination
Operating system 18 process creation and termination
 
Processes
ProcessesProcesses
Processes
 
Systems Programming Assignment Help - Processes
Systems Programming Assignment Help - ProcessesSystems Programming Assignment Help - Processes
Systems Programming Assignment Help - Processes
 
UNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdfUNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdf
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process Management
 
Os
OsOs
Os
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Process
ProcessProcess
Process
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture 5 process concept
Lecture 5   process conceptLecture 5   process concept
Lecture 5 process concept
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 

More from Dr. Loganathan R

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfDr. Loganathan R
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdfDr. Loganathan R
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersDr. Loganathan R
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Dr. Loganathan R
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information SecurityDr. Loganathan R
 

More from Dr. Loganathan R (20)

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
 

Recently uploaded

Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 

Recently uploaded (20)

Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 

3 process management

  • 1. Processes 1. Process Concept 2. Process Scheduling 3. Operations on Processes 4. Interprocess Communication
  • 2. 1. Process Concept • An operating system executes a variety of programs: – Batch system – jobs – Time-shared systems – user programs or tasks • The terms job and process are used almost interchangeably • 1.1 The Process – a program in execution; process execution must progress in sequential fashion – A process includes: • program counter - current activity • Stack - temporary data(function, parameters, return addresses, and local variables) • data section - global variables • heap - dynamically allocated memory during process run time Loganathan R, CSE, HKBKCE 2
  • 3. 1. Process Concept Contd… Process in Memory • A program by itself is not a process • A program is a passive entity, a file containing a list of instructions stored on disk (often called an executable file) • A process is an active entity, with a program counter specifying the next instruction to execute and a set of associated resources Loganathan R, CSE, HKBKCE 3
  • 4. 1. Process Concept Contd… 1.2 Process State • As a process executes, it changes state, state of a process is defined in part by the current activity of that process – new: The process is being created – running: Instructions are being executed – waiting: The process is waiting for some event to occur – ready: The process is waiting to be assigned to a processor – terminated: The process has finished execution Loganathan R, CSE, HKBKCE 4
  • 5. 1. Process Concept Contd… 1.3 Process Control Block (PCB) also called task control block contains information associated with each process • Process state - new, ready, running, waiting, halted • Program counter - the address of the next instruction to be executed • CPU registers - accumulators, index registers, stack pointers, and general- purpose registers • CPU scheduling information - process priority, pointers to scheduling queues and scheduling parameters • Memory-management information - value of the base and limit registers, the page tables, or the segment tables • Accounting information - the amount of CPU and real time used, time limits, account numbers, job or process numbers • I/O status information - list of I/O devices allocated to the process, a list of open files 1.4 Threads • A process is a program that performs a single thread of execution • Single thread of control allows the process to perform only one task at one time • Multiple threads of execution perform more than one task at a time Loganathan R, CSE, HKBKCE 5
  • 6. 1. Process Concept Contd… Process Control CPU Switch From Process to Process Block (PCB) Loganathan R, CSE, HKBKCE 6
  • 7. 2. Process Scheduling • Multiprogramming and Time Sharing switch the CPU among processes so frequently that users can interact with each program • Process Scheduler selects an available process (possibly from a set of several available processes) for program execution on the CPU 2.1 Scheduling Queues • Job queue – set of all processes in the system • Ready queue – set of all processes residing in main memory, ready and waiting to execute • Device queues – set of processes waiting for an I/O device. Each device has its own device queue • Processes migrate among the various queues Loganathan R, CSE, HKBKCE 7
  • 8. 2. Process Scheduling Contd… Ready Queue And Various I/O Device Queues Loganathan R, CSE, HKBKCE 8
  • 9. 2. Process Scheduling Contd… • Representation of Process Scheduling is Queuing Diagram • Rectangle represents a queue, Circle represent the resource and arrow indicate the flow of processes • New process is initially put in the ready queue and waits there until it is selected for execution, or is dispatched • Once the process is allocated the CPU and is executing, the events may occur are: The process could issue an I/O request and then be placed in an I/O queue The process could create a new sub process and wait for the sub process's Termination The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue Loganathan R, CSE, HKBKCE 9
  • 10. 2. Process Scheduling Contd… 2.2 Schedulers • The selection processes from those queue is carried out by the appropriate scheduler • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue  Executes much less frequently, minutes may separate the creation of one new process and the next  controls the degree of multiprogramming (the number of processes in memory)  take more time to decide which process should be selected for execution  select a good process mix of I/O-bound(spends more of its time doing I/O) and CPU-bound (spends more of its time doing computations) processes)  Time-sharing systems (UNIX &Windows) have no long-term scheduler but simply put every new process in memory for the short-term scheduler • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU  select a new process for the CPU frequently i.e. executes at least once every 100 milliseconds  Must be fast. i.e. If it takes 10 milliseconds to decide to execute a process for 100 milliseconds, then 10/(100 + 10) = 9 percent of the CPU is being wasted simply for scheduling the work Loganathan R, CSE, HKBKCE 10
  • 11. 2. Process Scheduling Contd… Medium Term Scheduler • Intermediate level of scheduling, removes processes from memory (and from active contention for the CPU) to reduce the degree of multiprogramming • The process can be reintroduced later into memory, and its execution can be continued where it left off(Swapping) Loganathan R, CSE, HKBKCE 11
  • 12. 2. Process Scheduling Contd… 2.3 Context Switch • When CPU switches to another process, the system must save the state(PCB) of the old process and load the saved state for the new process is known as context switch • Context-switch time is overhead; the system does no useful work while switching • Time dependent on hardware support – Sun UltraSPARC provide multiple sets of registers, which requires changing the pointer to the current register set Loganathan R, CSE, HKBKCE 12
  • 13. 3. Operations on Processes 3.1 Process Creation • Parent process create children processes via create-process systemcall, which, in turn create other processes, forming a tree of processes • Processes are identified according to a unique process identifier(or pid), which is typically an integer number A tree of process on a Solaris system Loganathan R, CSE, HKBKCE 13
  • 14. 3. Operations on Processes Contd… • When a Process creates new process, • Resource sharing • Parent and children share all resources • Children share subset of parent’s resources • Parent and child share no resources • Execution possibilities • Parent and children execute concurrently • Parent waits until children terminate • Address space possibilities • Child duplicate of parent • Child has a program loaded into it Loganathan R, CSE, HKBKCE 14
  • 15. 3. Operations on Processes Contd… Process Creation UNIX examples • fork system call creates new process • exec system call used after a fork to replace the process’s memory space with a new program int main() { pid_t pid; pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); } else { /* parent process */ /* parent wait for the child to complete */ wait (NULL); printf ("Child Complete"); Process Creation exit(0); } } C Program Forking Separate Process Loganathan R, CSE, HKBKCE 15
  • 16. 3. Operations on Processes Contd… 3.2 Process Termination • Process executes last statement and asks the operating system to delete it (using exit()) – Output data from child to parent (via wait()) – Process’s resources are deallocated by operating system • Parent may terminate execution of children processes (abort) – Child has exceeded allocated resources – Task assigned to child is no longer required – If parent is exiting • Some operating system do not allow child to continue if its parent terminates – All children terminated - cascading termination Loganathan R, CSE, HKBKCE 16
  • 17. 4. Interprocess Communication • Processes executing concurrently in the operating system may be either independent processes or cooperating processes • Independent process cannot affect or be affected by the execution of another process • Cooperating process can affect or be affected by the execution of another process • Advantages of process cooperation • Information sharing • Computation speed-up – break into subtasks, each of which will be executing in parallel • Modularity - dividing the system functions into separate processes or threads • Convenience - individual user may work on many tasks at the same time • Cooperating processes require an interprocess communication (IPC) mechanism to exchange data and information Loganathan R, CSE, HKBKCE 17
  • 18. 4. Interprocess Communication Contd… • Two fundamental models of Interprocess communication • Shared memory • a region of memory that is shared by cooperating processes is established then exchange information takes place by reading and writing data to the shared region • Message passing • communication takes place by means of messages exchanged between the cooperating processes Message passing Shared memory Loganathan R, CSE, HKBKCE 18
  • 19. 4. Interprocess Communication Contd… 4.1 Shared memory Systems • A shared-memory region resides in the address space of the process creating the shared-memory • Other processes that wish to communicate using this shared-memory segment must attach it to their address space • The form of the data and the location are determined by these processes and are not under the operating system's control • Example : Producer-Consumer Problem - Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process • Example : compiler may produce assembly code, which is consumed by an assembler, in turn, may produce object modules, which are consumed by the loader • To allow producer and consumer processes to run concurrently, we must have available a buffer of items that can be filled by the producer and emptied by the consumer • unbounded-buffer places no practical limit on the size of the buffer (customer may wait) • bounded-buffer assumes that there is a fixed buffer size(both waits) Loganathan R, CSE, HKBKCE 19
  • 20. 4. Interprocess Communication Contd… Bounded-Buffer – Shared-Memory Solution • Shared buffer is implemented as a circular array with two logical pointers: in and out • The buffer is empty when in == out; the buffer is full when ((in + 1) % BUFFER_SIZE) == out. #define BUFFER_SIZE 10 typedef struct { ... } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; Loganathan R, CSE, HKBKCE 20
  • 21. 4. Interprocess Communication Contd… Code for the producer and consumer processes • Producer process item nextProduced; while (true) { /* produce an item in nextProduced */ while ( ( ( in + 1) % BUFFER-SIZE) == out) ; /* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; } • Consumer process item nextConsumed; while (true) { while (in == out) ; //do nothing nextConsumed = buffer[out]; out = (out + 1) % BUFFEFLSIZE; /* consume the item in nextConsumed */ } Loganathan R, CSE, HKBKCE 21
  • 22. 4. Interprocess Communication Contd… 4.2 Message-Passing Systems • Mechanism for processes to communicate and to synchronize their actions • Message system – processes communicate with each other without resorting to shared variables • IPC facility provides two operations: – send(message) – message size fixed or variable – receive(message) • If ProcessP and Q wish to communicate, they need to: – establish a communication link(Not Phsical) between them – exchange messages via send/receive • Implementation of communication link – physical (e.g., shared memory, hardware bus or network) – logical (e.g., logical properties) Loganathan R, CSE, HKBKCE 22
  • 23. 4. Interprocess Communication Contd… • Methods for logically implementing a link and send() / receive () operations • Direct or indirect communication • Synchronous or asynchronous communication • Automatic or explicit buffering 4.2.1 Naming - Processes must name each other explicitly in Direct Communication • send (P, message) – send a message to process P • receive(Q, message) – receive a message from process Q • Properties of communication link • Links are established automatically • A link is associated with exactly one pair of communicating processes • Between each pair there exists exactly one link • The link may be unidirectional, but is usually bi-directional • In Symmetry addressing - both the sender process and the receiver process must name the other i.e. send(P, message) and receive (Q, message) • In asymmetry addressing - only the sender names the recipient • send(P, message)—Send a message to process P • receive(id, message)—-Receive a message from any process; id will be the name of the sender process (disadvantage – Changing id of a process necessitates all references to the old id) Loganathan R, CSE, HKBKCE 23
  • 24. 4. Interprocess Communication Contd… • Messages are sent to and received from mailboxes or ports • Each mailbox has a unique id • Processes can communicate only if they share a mailbox • Primitives : send(A, message and receive(A, message) where A is a mailbox • Properties of communication link • Link established only if processes share a common mailbox • A link may be associated with more than two processes • Each pair of processes may share several communication links • Link may be unidirectional or bi-directional • Mailbox sharing • P1, P2, and P3 share mailbox A and P1, sends to A; Who gets the message? • Allow a link to be associated with at most two processes • Allow only one process at a time to execute a receive operation • Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was. The system may define an algorithm(RR) for selection • A mailbox may be owned either by a process or the OS • If the mailbox is owned by a process, it is distinguished as owner (only receive) & user (only send) • A mailbox owned by OS has an existence of its own and allows a process to – create a mailbox , send and receive messages through mailbox and destroy a mailbox • The process that creates a new mailbox is the owner and it can only receive messages, ownership and receiving privilege may be passed to other processes through appropriate system calls Loganathan R, CSE, HKBKCE 24
  • 25. 4. Interprocess Communication Contd… 4.2.2 Synchronization • Different design options for implementing send() and receive () primitives • Message passing may be either blocking or non-blocking also known as synchronous or asynchronous. • Blocking is considered synchronous – Blocking send - sender block until the message is received – Blocking receive - receiver block until a message is available – rendezvous between the sender and the receiver • Non-blocking is considered asynchronous – Non-blocking send - sender send the message and continue – Non-blocking receive - receiver receive a valid message or null Loganathan R, CSE, HKBKCE 25
  • 26. 4. Interprocess Communication Contd… 4.2.3 Buffering • Messages exchanged by communicating processes reside in a temporary queue • Queue of messages attached to the link is implemented in one of three ways – Zero capacity – The queue length is zero, no messages can wait. Sender must wait for receiver (rendezvous) – Bounded capacity – finite length of n messages. Sender must wait if link full – Unbounded capacity – infinite length Sender never waits Loganathan R, CSE, HKBKCE 26