Difference between revisions of "COMP3000 Operating Systems W22: Tutorial 6"

From Soma-notes
Jump to navigation Jump to search
(Created page with "In this tutorial you will be learning about two implementations of the [https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem producer-consumer problem], a classic e...")
 
m
Line 8: Line 8:


You get 1.5 marks for submitting answers that shows your effort and 0.5 for checking in, making this tutorial worth 2 points total.
You get 1.5 marks for submitting answers that shows your effort and 0.5 for checking in, making this tutorial worth 2 points total.
==A: Getting Started==
Download [https://people.scs.carleton.ca/~lianyingzhao/comp3000/w22/tut6/3000pc.zip 3000pc.zip], unpack, and run <tt>make</tt> to compile <tt>3000pc-fifo</tt> and <tt>3000pc-rendezvous</tt>.
Note that these programs take 3 arguments each:
* The number of events to process
* The number of events to produce before the producer sleeps for 1 second
* The number of events to consume before the consumer sleeps for 1 second
1. Run both programs with the same arguments of your choice. Do this a few times with different arguments. Do they behave the same way? Do you notice any differences?  (again, no “correct” answers but just play with them and document your observations)
2. Repeat the above experiment, this time running each program under <tt>strace</tt> (with the <tt>-f</tt> flag to trace children too). Do you notice any difference in the system calls each program makes? Remember to ignore the lines before <tt>main()</tt> that might be distracting, e.g., start looking around and after the <tt>clone()</tt> system call.

Revision as of 00:19, 24 February 2022

In this tutorial you will be learning about two implementations of the producer-consumer problem, a classic example of a concurrency problem. The class textbook covers concurrency in great detail in Chapters 25-34, and the producer-consumer problem is covered in Chapter 30 (Condition Variables) and Chapter 31 (Semaphores). While you can look at this part of the textbook, note that we will not be covering this material in the same level of detail, as should be clear from this tutorial.

Tutorials are graded based on participation and effort (so no need to try to have the “correct” answers — what matters is the process), but you should still turn in your work. Even if you have no idea about certain tasks or disagree about something, still make sure to document your confusions/opinions that reflect your thinking about that task. Submit your answers on Brightspace as a single text file named "<username>-comp3000-t6.txt" (where username is your MyCarletonOne username). The first four lines of this file should be "COMP 3000 Tutorial 6", your name, student number, and the date of submission.

The deadline is usually four days after the tutorial date (see the actual due date and time on the submission entry). Note that the submission entry is enforced by the system, so you may fail to get the effort marks even if it is one minute past the deadline.

You should also check in with your assigned TA online (by responding to the poll in the Teams channel tutorials-public or the private channel). Your TA will be your first point of contact when you have questions or encounter any issues during the tutorial session.

You get 1.5 marks for submitting answers that shows your effort and 0.5 for checking in, making this tutorial worth 2 points total.


A: Getting Started

Download 3000pc.zip, unpack, and run make to compile 3000pc-fifo and 3000pc-rendezvous.

Note that these programs take 3 arguments each:

  • The number of events to process
  • The number of events to produce before the producer sleeps for 1 second
  • The number of events to consume before the consumer sleeps for 1 second

1. Run both programs with the same arguments of your choice. Do this a few times with different arguments. Do they behave the same way? Do you notice any differences? (again, no “correct” answers but just play with them and document your observations) 2. Repeat the above experiment, this time running each program under strace (with the -f flag to trace children too). Do you notice any difference in the system calls each program makes? Remember to ignore the lines before main() that might be distracting, e.g., start looking around and after the clone() system call.