Find more Software Project Management Remote Jobs posted recently Worldwide
Required CPP Programming freelancer for C++ project job
Posted at - Sep 27, 2017
This is the reference program:
https://stackoverflow.com/questions/28592437/c-create-two-processes-which-can-generate-odd-and-even-integersWrite a simple sequence-number system through which two concurrent processes, P1 and P2 each obtain unique integers in the range [1, 100]. Use the fork() call to create P1 and P2. Given a file, F, containing a single number, each process must perform the following steps:
a. Open F.
b. Read the sequence number N from the file.
c. Close F.
d. Output N and the process' PID (either on screen or test file).
e. Increment N by 1
f. Open F.
g. Write N to F.
h. Flush F.
i. Close F.
What are the problems that you observe? Describe the behavior of your program and provide evidence for your conclusion in form of test-output. NOTE: All programs must compile and execute on the CSE machines. It is imperative that the sequence number files is located on the local disk. On Linux, the \tmp directory is located on the local file system.
Please use semaphores to solve this problem. There must be locks on the file when accessing them. And please make sure that both the processes P1 and P2 print the numbers in a perfect sequence. The numbers should not be jumbled.
The solution should not have any deadlocks.
About the recuiterMember since Sep 27, 2017 Akash C.
from Delhi, India