Question: Project #1: Process Identifier (PID) Organizer The process identifier organizer is responsible for managing process identifiers. Process Identifier (process ID or PID) is a number
Project #1: Process Identifier (PID) Organizer The process identifier organizer is responsible for managing process identifiers. Process Identifier (process ID or PID) is a number used by most operating system kernelssuch as those of Unix, macOS and Windowsto uniquely identify an active process. Whenever a new process is created it will be given a unique process identifier by the operating system kernel. When the process terminates (or completes execution) it will give back this Process Identifier, and this Process Identifier can be reassigned later for other new processes. (no two active processes can have the same pid). You are required to make use of the topics covered during the labs and lectures (threads, mutex locks) by designing and implementing an abstract program that simulate the Process Identifier (PID) Organization. Create a data structure that represent the process identifiers. Implement following functions for obtaining and releasing a Process Identifier(pid): int allocate map(void): Creates and initializes a data structure in order to maintain the list of available pids; returns -1 if unsuccessful, 1 if successful int allocate pid(void): Find next available pid and allocate (assign) it to the new process; returns -1 if unable to allocate a pid (all pids are in use). void release pid(int pid): Releases old pid by making it available again for new processes. Create multiple threads that represent processes to test your functions, each thread will request a pid, sleep for a random period of time, and then release the pid. Ensure that your program is safe from race conditions by using pthreads mutex locks. Hint: Check the sleep() function, you can pass to it an integer value that represent the number of seconds to sleep
(written in C language using Ubuntu preferably)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
