Co-operating processes

            Processes can cooperate with each other to accomplish a single task.
 Cooperating processes can:

  • Improve performance by overlapping activities or performing work in parallel.
  •  Enable an application to achieve a better program structure as a set of cooperating processes, where each is smaller than a single monolithic program.

 Easily share information

• Process cooperation (i.e., interprocess communication) deals with
– Passing information between processes/threads
– Making sure that processes/threads do not interfere with each other
– Ensuring proper sequencing of dependent operations
• These issues apply to both processes and threads.
• A cooperating process can affect or be affected by the execution of another process.
Cooperating Processes Approach

Any approach to process cooperation requires that

  • No two processes may be simultaneously inside their critical regions.
  • No assumptions may be made about speeds or the number of CPUs.
  • No process running outside of its critical region may block other processes.
  • No process should have to wait forever to enter its critical region.

Advantages of process cooperation

– Information sharing
– Computation speed-up
– Modularity
– Convenience

 

Issues for Cooperating Processes

• Race conditions
– A race condition is a situation where the semantics of an operation on shared memory are affected by the arbitrary timing sequence of collaborating processes.
• Critical regions
– A critical region is a portion of a process that accesses shared memory.
• Mutual exclusion
Mutual exclusion is a mechanism to enforce that only one process at a time is allowed into a critical region

 

Scheduler:

On most multitasking systems, only one process can truly be active at a time - the system must therefore share its time between the executions of many processes. This sharing is called scheduling. Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. It refers to the way processes are assigned priorities in a priority queue. This assignment is carried out by software known as a scheduler. The OS’s scheduler decides when to run which process.
 .                                      
Types of Schedulers

  1. First-Come, First-Served  (FCFS)
  2. Round-Robin   (RR)
  3. Shortest-Job-First  (SJF)
  4. Priority Scheduling  (PS)

 

 First-Come, First-Served (FCFS)

The FCFS scheduler simply executes processes to completion in the order they are submitted.FCFS scheduling algorithm is non-preemptive

 

Shortest-Job-First (SJF)

 The SJF scheduler is exactly like FCFS except that instead of choosing the job at the front of the queue, it will always choose the shortest job (i.e. the job that takes the least time) available. Sorted list is used to order the processes from longest to shortest, when adding a new process/task.

Round-Robin (RR)

RR is a preemptive scheduler, which is designed especially for time-sharing systems. In other words, it does not wait for a process to finish or give up control. Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue

 

Priority (PRI)
A priority is associated with each process.Processes with equal priorities may be scheduled in accordance with FCFS.