程序代写代做 • Compile and run the program critical.c. To run this program you need to use sudo (i.e., use the command: sudo ./critical). Record the output. Briefly explain what this program does and how the scheduling gives rise to the observed behaviour. Include in your report a timing diagram; be sure to show the state of each task (including the main routine) at all times.

• Compile and run the program critical.c. To run this program you need to use sudo (i.e., use the command: sudo ./critical). Record the output. Briefly explain what this program does and how the scheduling gives rise to the observed behaviour. Include in your report a timing diagram; be sure to show the state of each task (including the main routine) at all times.

• Modify the code so that the mutexes are no longer “commented-out”. Run the program again (using sudo) and record the output. Briefly explain the execution of the modified program. Draw a timing diagram of the modified program.

Examine the code for program multithread.c and make sure that you understand what it does.
• Run the code and record the output. To run this program you need to use sudo (i.e., use the command: sudo ./multithread). Briefly explain what this program does and how the scheduling gives rise to the observed behaviour. Include in your report a timing diagram; be sure to show the state of each task (including the main routine) at all times.
Modify the threadA function so that after printing half the letters it increases the priority of threadB using the instructions:
• Run the modified program (using sudo) and record the output. Draw a timing diagram showing the state of each task (including the main routine) at all times. Explain the scheduling of the threads. Modify the code to decrease the priority of threadB after threadA has printed half its letters. Report what happens and comment on this result. Modify the priority of only the executing thread and report what happens when the priority is increased and when it is decreased. Comment on and explain these results.

• Modify the original program so that threadA sleeps for 1 millisecond after printing half its letters (use the nanosleep command). Run the code (using sudo) and record the output. Draw a timing diagram and explain the scheduling of the threads. Include a print-out of your program code.

• Change the scheduling policy used by multithread.c to be SCHED RR rather than SCHED FIF0. Perform experiments to determine how these scheduling policies differ. Describe the experiments that you performed and summarise the results. Describe in your report how both scheduling policies determine the scheduling of tasks both when threads have equal priority and when threads have unequal priorities. Include a print-out of your program code.