You are to write a program which will reserve tickets for a concert. Our concert hall is very small and has only 5 rows of 8 seats each. A random access file is to be used to keep track of which seats have been reserved. Each seat will have one byte reserved to indicate whether it is taken or not. The seat s in row r is recorded in byte (8*r + s-1) of the file where r=1, ..., 5; s=1, ..., 8. You may simply record an "O" [as Occupied] in byte(8*r + s-1) to indicate that the seat is Occupied. You may create the random access file prior to running the programs. It simply needs to have zero length. Run your program [login to view URL] twice and log the output using script or photo in concertA.log.
Every request will be followed by a confirmatory response from the program with the reserved seats numbers in their corresponding [login to view URL] time and date of reservation should also be printed in the confirmation so that one can ascertain at what time and date the request was entered. Your data file should be named [login to view URL] which should be created first and should have its protection set by the commands:
$ touch [login to view URL]
$ chmod ug+lrw [login to view URL]
Your program should prompt for a function:$ Reserve or Display>Entering D results in a display of the occupied seats while entering an R causes prompts for the row number and then for a range of seat numbers. EnteringQ quits the program. All file entries should be in raw I/O format[using buffers]with error control and boundary checking. It should be possible to enter a single symbol(char)to reserve one seat.
Reserve seats 2-5in row 1
Reserve seats 4-7in row 2
Attempt to reserve seat 4in row 2–rejected
Reserve seat 3 in row 1Display reserved seats:
Reserve seats 2-3 in row 4
Attempt to reserve seats 5-9in row 5–rejected
Display reserved seats
Multiple copies of the program should be able to run at the same time (started with separate terminal windows & run commands). To obtain a seat reservation for x adjacent seats in row r, the program should lock the locations corresponding to that row, make the reservation, and then unlock the locations. Use the blocking option so that you wait if the lock is not available. Your test run should show two programs running simultaneously both trying to lock row 3and one being forced to wait. Run two copies of your program [login to view URL]) from two windows at the same time and make logs [login to view URL] and [login to view URL] one for each window & run.
Possible C/C++ library includes
<sys/file.h>, <stdio.h>, <stdlib.h>, <signal.h><sys/types.h>, <unistd.h>, <fcntl.h>, <time.h>
Practicing Operating Systems Techniques:
-I/O analysis and error handling
-Random access file using lseek, read, and write system calls
-lock/flock and unlock/flock a position in the file-wait for a lock
11 freelancers are bidding on average $43 for this job
I'm a Google certified Software Developer (AAD). Having plenty of experience in multi-tier diverse C++/VC++ application development. You'll get your job done perfectly. Have a look at my portfolio and reviews.