Wednesday, February 16, 2011

PROCESS MANAGEMENT

Briefing on communications among processes

  • 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 P and Q wish to communicate, they need to:
  • establish a communication link between them.
  • exchange messages via send/receive.



Mutual Exclusion

  • Mutual exclusion algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections.
  • A critical section is a piece of code in which a process or thread accesses a common resource.
  • The critical section by itself is not a mechanism or algorithm for mutual exclusion.
  • A program, process, or thread can have the critical section in it without any mechanism or algorithm which implements mutual exclusion.


Synchronization

  • Message passing may be either blocking or non-blocking
  • Blocking is considered synchronous
  • Blocking send has the sender block until the message is received
  • Blocking receive has the receiver block until a message is available
  • Non-blocking is considered asynchronous
  • Non-blocking send has the sender send the message and continue
  • Non-blocking receive has the receiver receive a valid message or null
  • Synchronization is timekeeping which requires the coordination of events to operate a system in unison.
  • The familiar conductor of an orchestra serves to keep the orchestra in time.


Deadlock

  • Deadlock can arise if four conditions hold simultaneously.
  • Mutual exclusion: only one process at a time can use a resource.
  • Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes.
  • No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task.



Recognize interaction and synchronization among process

  • Many systems provide hardware support for critical section code
  • Uniprocessors – could disable interrupts
  • Currently running code would execute without Preemption.
  • Generally too inefficient on multiprocessor systems
  • Operating systems using this not broadly scalable
  • Modern machines provide special atomic hardware instructions
  • Atomic = non-interruptable
  • Either test memory word and set value or swap contents of two memory words