计算机代写 6CCE3RSC/7CCEMRTS

6CCE3RSC/7CCEMRTS
Assignment:Real-time Programming with pthreads 21st February 2022
For this assignment, you will need the template code critical.c and multithread.c. Download these from the module¡¯s KEATS page and save it to your computer. Use the following command to compile the source code:
gcc filename.c -o filename -lrt -lpthread

Copyright By PowCoder代写 加微信 powcoder

where filename is the name of the source code file. The resultant executable should be run using sudo,
i.e., use the command:
sudo ./filename
Check that the above works for the source code provided, and complete the following exercises. Examine the code for program multithread.c and make sure that you understand what it does.
1. Run the code and report 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.
2. Modify the threadA function so that after printing half the letters it the following two instructions are called:
param.sched priority = priority min+2;
pthread setschedparam(threadB id,policy,&param);
Run the modified program and record the output. Explain the effect of this change on the observed behaviour.
3. Use use the nanosleep command to modify the original program so that threadA sleeps for 1 millisecond after printing half its letters. Run the code and report the output. Explain the effect of this change on the observed behaviour.
Dr M. Howard & Dr H.-K. of Engineering King¡¯s College London

4. Compile and run the program critical.c. Report the output. Briefly explain what this program does and how the scheduling gives rise to the observed behaviour.
5. Modify the code so that the mutexes are no longer ¡°commented-out¡±. Run the program and report the output. Briefly explain the execution of the modified program.
Completed assignments should be submitted to KEATS on 4pm, 14th March 2022.
Your report must be no longer than two A4-pages (all pages contained in the file beyond this limit will be removed from the file and discarded prior to marking). It should be submitted as a single PDF with a minimum font size of 11pt, and margins of no less than 2cm.
This assignment is worth 30% of the module mark.
Dr M. Howard & Dr H.-K. of Engineering King¡¯s College London

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com