Be sure you have read, or at least skimmed, Chapters 25, 26, 27, 28, 30, 31, 32, and 34 of the textbook. (Yes, I'm skipping chapters 29 and 33.)
Answer the following questions. You may write out your answers by hand and scan them, or you may use a word processor or other program, but please turn in a PDF or plain text file. (No links to shared files on Google Drive please, and no word-processor files.) Turn it in by putting it in your course “TurnIn” folder on Google Drive. Please be sure to include your name somewhere in the file, so when I print it for grading I know whose work it is. (In the pledge is fine.)
Printer process:
while (true) { outFileName = generateFileToPrint(); enqueue(printQueue, outFileName); }
Printer user process:
while (true) { if (!empty(printQueue)) { fileToPrint = dequeue(printQueue); print(fileToPrint); } }
Do we need some sort of locking to make this work right? If so, say how many locks you think would be needed and where you would put calls to lock() and unlock().
// shared variables semaphore mutex(1); // initial value 1 // process while (true) { down(mutex); do_critical_region(); up(mutex); do_non_critical_region(); }
Answer the following questions.
Include with your assignment the following information.
For programming assignments, please put it a separate file. (I strongly prefer plain text, but if you insist you can put it in a PDF -- just no word-processor documents or Google Drive links please.) For written assignments, please put it in your main document.
This should include the Honor Code pledge, or just the word “pledged”, plus at least one of the following about collaboration and help (as many as apply). Text in italics is explanatory or something for you to fill in; you don't need to repeat it!
This should be a brief essay (a sentence or two is fine, though you can write as much as you like) telling me what if anything you think you learned from the assignment, and what if anything you found interesting, difficult, or otherwise noteworthy.