Operating System Fundamentals
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
EECS 3221 – Operating System Fundamentals
1. The readFile(), if called with filename and struct thread pointer as arguments, can read the
content of file for you and populate the threads’ information in a dynamic array of type struct
thread. Such a pointer threads is provided there in main() and you can use it. readFile()returns
the number of threads read from the file and you must connect it with the threadCount variable
provided in the main().2. You may add some more members to struct thread if required. If you want to initialize those
additional members, then you can possibly do that in readFile().
3. The main() already contains some code and hints to guide you. However, there is no call to
readFile() or code to initialize, execute and synchronize threads. You must perform these tasks in
a suitable way there. startClock() invocation as given in main() is required to initiate the
program’s internal clock, so do not remove it.
4. The threadRun() function also contains the code that a thread must run. However, the
synchronization logic (entry/exit section) is missing. Add the suitable code before and after the
critical section.
5. You will need to create and use POSIX pthreads and semaphore(s) to implement the required logic.
6. The image below shows the expected output for the sample input file (sample2_in.txt) provided with
this assignment. In this output when there are multiple threads finishing (or may be starting) at the
same time, e.g. at t=5 both t02 and t07 are finished, then their order may switch and may be different
than their critical section order, because start/finish is out of critical section and unsynchronized.
However, the critical section order, e.g. in t=5 both t02 and t07 perform their critical section, must
always be as per our synchronization requirement. Also, you have to make sure that a thread must
be started at its creation time as per the input file i.e. “is started” message of thread must have the
same time stamp as mentioned in the input file:
7. Do not change the code in the functions: logStart(), logFinish(), startClock(),
getCurrentTime(). Also, do not change the signature of any of the functions that are given in the
code provided.