SWEN 342
Pthreads Demo Activity
- Verify that the following code works on your system.
- pthreads_demo
- Refer to Wikipedia Pthreads
- Library call for pthread_create
- Now use the command line parameters to make a modification thread operation
possibly including spin loops to assess impacts or other experiments.
Experiments:
- Remove rand timing in perform function and make it 1 + (2 * thread number). Record result.
- Add a spin loop helper function that takes one parameter as the number of seconds.
Replace the call to sleep with the call to the new spin_loop(int seconds) call.
You will need to experiment with the number of loops to get the right timing.
- Added a command line parameter reverse which changes the timing to 1 * (2 * (5 - thread_number))
and report your observations.
- Create a pthreads folder in your GitHub classroom account. Use this folder to submit the
updated code and your report.
- Report template in PDF and docx formats: PDF
docx
L. Kiser Feb. 13, 2023