0% found this document useful (0 votes)
27 views2 pages

Spring 2024 - CS604P - 2

Uploaded by

MUHAMMAD MUSTAFA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Spring 2024 - CS604P - 2

Uploaded by

MUHAMMAD MUSTAFA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Operating System (CS604) Total marks = 20

Assignment # 02 Deadline Date

Spring 2024 June 24, 2024

Please carefully read the following instructions before attempting the assignment.

RULES FOR MARKING


It should be clear that your assignment would not get any credit if:
 The assignment is submitted after the due date.
 The submitted assignment does not open, or the file is corrupted.
 Strict action will be taken if the submitted solution is copied from any other student or the
internet.

You should consult the recommended books to clarify your concepts, as handouts are insufficient.

Assignment Submission:
You are supposed to submit your assignment in Doc or Docx format.
Any other formats, such as scanned images, PDF, zip, rar, ppt, and BMP, will not be accepted.
You are required to send the asnwer of Question No. 1 in the same Word file.

OBJECTIVE
The objective of this assignment is to provide hands-on experience in the:
 To introduce the critical-section problem, whose solutions can be used to ensure the
consistency of shared data. To present both software and hardware solutions of the
critical-section problem.

NOTE

No assignment will be accepted after the due date via email in any case (whether it is due to load
shedding or internet malfunctioning, etc.). Hence, refrain from uploading assignments within the
last hour of the deadline. It is recommended that the solution file be uploaded at least two days
before its closing date.

Please consult your instructor before the deadline if you find any mistake or confusion in the
assignment (Question statement). After the deadline, no queries will be entertained in this
regard.

For any query, feel free to email me at:


[email protected]
Questions No 01 20 marks

You are required to find out mistakes in the following pseudo code. Make correction in
pseducode and explain working of this puesudo code.

Pseudocode Example:

printer_queue = Queue()
printer_lock = Lock()

def printer_daemon():
while True:
if not printer_queue.empty():
printer_lock.acquire()
job = printer_queue.get()
print(f"Printing job: {job}")
time.sleep(2)
print(f"Completed job: {job}")
printer_lock.release()

def send_print_job(employee_id, job):


print(f"Employee {employee_id} is sending job: {job}")
printer_queue.put(job)
time.sleep(1)

printer_thread = Thread(target=printer_daemon, daemon=True)

employees = [
(1, 'Report_A'),

(3, 'Report_C')
]

for emp_id, job in employees:


Thread(target=send_print_job, (emp_id, job)).start()

You might also like