Have you ever had to create cooperating processes or threads as part of a school
ID: 3872171 • Letter: H
Question
Have you ever had to create cooperating processes or threads as part of a school assignment, or for work, or some other outside project? If so, what did the processes/threads do and what kind(s) of data did you have to share among them? Did you use shared memory or message passing for communication of data? Why did you choose the approach you did? If you have never written cooperating processes/threads, try to imagine a situation where you might have to do so and discuss how you'd plan to implement the communications.
Explanation / Answer
Yes, I have created threads during my collage's assignment.
There are two type of process actually OS supports one is independent process and other one is cooperating Processes.
Independent process are process that run or execute indepenedendly and do not share their memory with other process.
In simple term we can say they do not communicate with other processes or run as standalone process.somethimes these prcoess are called heavy weight process beacuse they take lot of memory to run and have not sharing nature.
On other hand we do have cooperating processes or threads. Threads are sometimes called light weigthed process. They can communicate with each other easily by sharing memory.
Did you use shared memory or message passing for communication of data?
Now here we take one simple example through which we can easily understand that what are the importance of threads in OS,how they work and where they are needed.
Producer and consumer problem is the best example to unserstand the thread concept. Producer consumer problem says we have two process and there should be some common memory or queue or buffer
which can be used by both the threads at the same time.Producer process produce something and at the same time consumer process consume whatever producer process produced in the buffer.
Now there are some protocol which tells that common memory should be shared always in a way where producer process won't try to add data into the memory if it's full and that the
consumer won't try to remove data from an empty memory.Now what is happing here if proceducer add something into queue then the consumer thread automatically notified that
something in queue for consumption and other side if thread is full then proceducer thread automatically notified that queue is full and you cannot add more items in the same.
so in OS a kind of look is taken/released by thread on common resource so that both the threads can communicate with each other.
It's like a simple trafic light, all the drivers check the trafic light and move ahead on the road. so trafic light is the medium or common resoruce which all driver shared on the road
and according to signals they move or stop.so the same concept OS followed for establishing communciation path between threads or light weighted processes.
Advantages of Cooperating Processes or Threads
1. Information Sharing
2. Concurrent execution so that execution speed can be fast.
In today's era, we have multiprocessors computers they all work on one principle and that is devided the large amount of work into small task and perform those small tasks parallel.
these is called concurrent execution which make ececution fast.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.