4.Cooperating Processes

  1. Independent process cannot affect or be affected by the execution of another process.
  2. Cooperating process can affect or be affected by the execution of another process
  3. Advantages of process cooperation
  • Information sharing
  • Computation speed-up
  • Modularity
  • Convenience

5. Interprocess Communication (IPC)

Mechanism for processes to communicate and to synchronize their actions.
  1. Message system – processes communicate with each other without resorting to shared variables.
  2. IPC facility provides two operations:
  • send(message) –message size fixed or variable
  • receive(message)

3. If P and Q wish to communicate, they need to:

  • establish a communication link between them
  • exchange messages via send/receiven Implementation of communication link
  • physical (e.g., shared memory, hardware bus) considered later
  • logical (e.g., logical properties) now

1.Concept on Process
An operating system executes a variety of programs:


  • Batch system – jobs
  • Time-shared systems – user programs or task

Textbook uses the terms job and process almost interchangeably.

Process – a program in execution; process execution must progress in sequential fashion.

A process includes:

  • program counter
  • stack

  • data section

Process State

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

  • ready: The process is waiting to be assigned to a processor

  • terminated: The process has finished execution.


Process Control Block


Information associated with each process.


Process ID

Process staten Program counter

CPU registersn CPU scheduling information


Memory-management information


Accounting information

I/O status information





Threads


In computer science, a thread of execution results from a fork of a computer program into two or more concurrently running tasks. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources.
On a single processor, multithreading generally occurs by time-division multiplexing (as in multitasking): the processor switches between different threads. This context switching generally happens frequently enough that the user perceives the threads or tasks as running at the same time. On a multiprocessor or multi-core system, the threads or tasks will generally run at the same time, with each processor or core running a particular thread or task. Support for threads in programming languages varies: a number of languages simply do not support having more than one execution context inside the same program executing at the same time.

2. Process Scheduling

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.
Ready Queue And Various I/O Device Queues





Device queues – set of processes waiting for an I/O device.
Processes migrate between the various queues.
Schedulers
Long-term scheduler (or job scheduler)selects which processes should be brought into the ready queue.
Short-term scheduler (or CPU scheduler) – selects whichprocess should be executed next and allocates CPU.





Short-term scheduler is invoked very frequently
(milliseconds)=> (must be fast).
Long-term scheduler is invoked very infrequently
(seconds, minutes) =>(may be slow).
The long-term scheduler controls the degree of multiprogramming.
Processes can be described as either:

  • I/O-bound process – spends more time doing I/O than computations, many short CPU bursts.
  • CPU-bound process – spends more time doing computations; few very long CPU bursts.
Context Switch

  • When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process.

  • Context-switch time is overhead; the system does no useful work while switching.

  • Time dependent on hardware support.

3.)Operations on Processes

--Process Creation

  1. Parent process creates children processes, which, in turn create other processes, forming a tree of processes.
  2. Resource sharing
  • Parent and children share all resources.
  • Children share subset of parent’s resources.
  • Parent and child share no resources.


3. Execution

  • Parent and children execute concurrently.
  • Parent waits until children terminate.

4.Address space

  • Child duplicate of parent.
  • Child has a program loaded into it.
UNIX examples

  • fork system call creates new process
  • fork returns 0 to child , process id of child for parent
  • exec system call used after a fork to replace the process’ memory space with a new program.

--Process Termination

Process executes last statement and asks the operating system to delete it (exit).

  • Output data from child to parent (via wait).
  • Process’ resources are deallocated by operating system.n Parent may terminate execution of children processes (abort).
  • Child has exceeded allocated resources.
  • Task assigned to child is no longer required.
  • Parent is exiting.

----------- Operating system does not allow child to continue if its parent terminates.

----------- Cascading termination.

  • In Unix, if parent exits children are assigned init as parent

1. What are the major activities of an Operating System with regards to Process Management?

The operating system is responsible for the following activities in connection with process management.
  • Process creation and deletion.
  • Process suspension (process is in I/O wait queue, or “swapped” out to disk, …) and resumption (move to ready queue or execution) – manage the state of the process.

  • Provision of mechanisms for:
  • Process synchronization - concurrent processing is supported thus the need for synchronization of processes or threads.
  • Process communication
  • Deadlock handling

2. What are the major activities of an Operating System with regards to Memory Management?

-Keep track of which parts of memory are currently being used and by whom.
-Decide which processes to load when memory space becomes available - long term or medium term scheduler.
-Mapping addresses in a process to absolute memory addresses - at load time or run time.
-Allocate and deallocate memory space as needed.
-Memory partitioning, allocation, paging (VM), address translation, defrag,
…Memory protection