Reference no: EM131065907
Write a C program that should run on Linux platform using gcc compiler. You are required to simulate threads creation and termination behavior by using POSIX threads library.
Input:
In the main program, first take the value for total number of threads and then ask user to provide the arrival time and CPU time (i.e. running time) for each thread.
Output:
Simulate the behavior of threads arrival, working and termination at a specific time interval (i.e. 500ms).
Requirements:
i. Name the program threadsimulator.c
ii. Create each thread as its arrival time comes, keep it in working state and terminate as the CPU time finishes.
iii. All creation and termination of threads must be done by using POSIX threads library.
iv. During the process, keep record of all non-terminated threads and show them in working state continuously.
v. The time duration between two intervals must be 500ms.
vi. Provide the commands to compile and run the program.
vii. Submit the program as a separate file. Don't embed the code in the assignment solution word file.
viii. Follow the sample interface and output for the program which is shown subsequently.
A sample interface and output for the program is shown as follows. Here to keep it short, only ten threads are taken. Your program should work for 1, 2, 3, 4, ..., up to 50 threads. The input from user is shown in bold.