Cooperation Process, Interprocess Communication - Operating Systems | CMSC 412, Study notes of Operating Systems

Material Type: Notes; Professor: Hollingsworth; Class: Operating Systems; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-ezw
koofers-user-ezw 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CMSC 412 – S04 (lect6)
Announcements
zProgram #2
Info on the Web
zReading
Chapter 7
zDon’t send me email from hotmail or yahoo
It’s auto-deleted as SPAM
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Cooperation Process, Interprocess Communication - Operating Systems | CMSC 412 and more Study notes Operating Systems in PDF only on Docsity!

Announcements

z^

Program #2– Info on the Web

z^

Reading– Chapter 7

z^

Don’t send me email from hotmail or yahoo– It’s auto-deleted as SPAM

Cooperating Processes

z^

Often need to share information between processes– information: a shared file– computational speedup:

  • break the problem into several tasks that can be run on different processors - requires several processors to actually get speedup - modularity: separate processes for different functions - compiler driver, compiler, assembler, linker - convenience: - editing, printing, and compiling all at once

Producer-consumer pair

z^

producer creates data and sends it to the consumer

z^

consumer read the data and uses it

z^

examples: compiler and assembler can be used as aproducer consumer pair

z^

Buffering– processes may not produce and consume items one by one– need a place to store produced items for the consumer

  • called a buffer
    • could be fixed size (bounded buffer) or unlimited (un-

bounded buffer)

Message Passing

z^

What happens when a message is sent?– sender blocks waiting for receiver to receive– sender blocks until the message is on the wire– sender blocks until the OS has a copy of the message– sender blocks until the receiver responds to the message

  • sort of like a procedure call• could be expanded into a remote procedure call (RPC) system

z^

Error cases– a process terminates:

  • receiver could wait forever• sender could wait or continue (depending on semantics)
    • a message is lost in transit
      • who detects this? could be OS or the applications

z^

Special case: if 2 messages are buffered, drop the older one– useful for real-time info systems

Signals

Signal Handler

Table

SigIOHandler{ } SigAlarmHandler{ }

SetSigAction(sig, handler)

Shared Memory

Process 1

Process 2 Shared Region

z^

Like Threads, but only part of memory shared

z^

Allows communication without needing kernel action– Kernel calls setup shared region

Problems with the Producer-Consumer

Shared Memory Solution

z^

Consider the three address code for the counterCounter Increment

Counter Decrement

reg

= counter 1

reg

= counter 2

reg

= reg 1

reg

= reg 2

counter = reg

1

counter = reg

2

z^

Now consider an ordering of these instructionsT

0

producer

reg

= counter 1

{ reg

T^1

producer

reg

= reg 1

{ reg

T^2

consumer

reg

= counter 2

{ reg

T^3

consumer

reg

= reg 2

{ reg

T^4

producer

counter = reg

1

{ counter = 6 }

T^5

consumer

counter = reg

2

{ counter = 4 }

Thisshouldbe 5!