Starting from:

$30

Operating Systems PROJECT 3 PARENT – CHILD LOCK FILES


CECS-326: Operating Systems
PROJECT 3
PARENT – CHILD LOCK FILES
Name: ____________________________________
Last, First
 ABSOLUTELY NO LATE PROJECTS WILL BE ACCEPTED
PROJECT DESCRIPTION:
Write a program using C/C++ to do the following. The program creates three child processes with child
numbers k = 0, 1, 2. Each child process attempts to acquire/create a lock file lock in num_tries times.
After each try, if still not successful, the child process sleeps for a random mod (sleeptime). If successful,
the child process displays contents of a text file text.dat (created by the user), removes the lock file, and
then exits with a return value being equal to the least significant 8 bits of its process ID. If after num_tries
times and the child process still cannot acquire/create the lock file, it displays “Unable to obtain lock file”
and kills itself with a signal value equal to its child number k. The arguments for the parent program
include the text.dat file name, num_tries, and sleeptime. The parent process should remove any leftover
lock files that may have existed from previous invocations before forking the child processes. The parent
program should wait for the child and displays “Wait on PID: childpid returns status of (status)” where
status is the status of the return in hexadecimal format.
Show output where all processes eventually gain access to the file. Show another output where at least one
process fails and displays “Unable to obtain lock file”.
DOCUMENTATION:
The project must be carefully documented. The write-up must include: one page of problem analysis and
discussion (include a flow chart or structure chart when relevant), program listing with proper comments,
one page of output listing using typical values of num_tries and sleeptime. The discussion should include
general considerations, UNIX function calls, any reasonable assumptions, and any other relevant
information. Attach this sheet as the front page of your project. Firmly staple the entire project together.
No folder is used.
END OF PROJECT 3 

More products