<< Chapter < Page Chapter >> Page >

Java condition variables:

  • wait(): release monitor lock on current object; put thread to sleep.
  • notify(): wake up one process waiting on the condition; this process will try to reacquire the monitor lock.
  • notifyall(): wake up all processes waiting on the condition; each process will try to reacquire the monitor lock. (Of course, only one at a timewill acquire the lock.)

Show how wait and notify solve the semaphore implementation problem. Mention that they can be used to implement anyscheduling mechanism at all. How do wait and notify compare to P and V?

Do the readers' and writers' problem with monitors.

Summary:

  • Not present in very many languages (yet), but extremely useful. Java is making monitors much more popular and well known.
  • Semaphores use a single structure for both exclusion and scheduling, monitors use different structures for each.
  • A mechanism similar to wait/notify is used internally to Unix for scheduling OS processes.
  • Monitors are more than just a synchronization mechanism. Basing an operating system on them is an important decision about the structure of theentire system.

Message passing

Up until now, discussion has been about communication using shared data. Messages provide for communication without shared data. Oneprocess or the other owns the data, never two at the same time.

Message = a piece of information that is passed from one process to another.

Mailbox = a place where messages are stored between the time they are sent and the time they are received.

Operations:

  • Send: place a message in a mailbox. If the mailbox is full, wait until there is enough space in the mailbox.
  • Receive: remove a message from a mailbox. If the mailbox is empty, then wait until a message is placed in it.

There are two general styles of message communication:

  • 1-way: messages flow in a single direction (Unix pipes, or producer/consumer):
  • 2-way: messages flow in circles (remote procedure call, or client/server):

Producer&consumer example:

Producer Consumer
int buffer1[1000];while (1) {-- prepare buffer1 --mbox.send(&buffer1);}; int buffer2[1000];while (1) {mbox.receive(&buffer2);-- process buffer2 --};

Note that buffer recycling is implicit, whereas it was explicit in the semaphore implementation.

Client&Server example:

Client Server
int buffer1[1000];mbox1.send("readrutabaga");mbox2.receive(&buffer); int buffer2[1000];intcommand[1000];mbox1.receive(&command);-- decode command ---- read file into buffer2 --mbox2.send(&buffer2);

Note that this looks a lot like a procedure call&return. Explain the various analogs between procedure calls and message operations:

  • Parameters:
  • Result:
  • Name of procedure:
  • Return address:

Why use messages?

  • Many kinds of applications fit into the model of processing a sequential flow of information, including all of the Unix filters.
  • The component parties can be totally separate, except for the mailbox:
    • Less error-prone, because no invisible side effects: no process has access to another's memory.
    • They might not trust each other (OS vs. user).
    • They might have been written at different times by different programmers who knewnothing about each other.
    • They might be running on different processors on a network, so procedure calls are out of the question.

Questions & Answers

anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
China
Cied
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
Ramkumar Reply
Berger describes sociologists as concerned with
Mueller Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Operating systems. OpenStax CNX. Aug 13, 2009 Download for free at http://cnx.org/content/col10785/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Operating systems' conversation and receive update notifications?

Ask