Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
c++ program on unix
#1
in this assignment, you will implement a program to handle hotel reservations requested by customers
at di erent locations connected to the \Fall-OS" hotel's database.
Suppose each customer is represented by a process and the body of the process consists of all the
reservations made by that customer. A customer can make reservations, payments cancellation of
reservations/payments. Two or more customers may be doing the same transactions at around the
same time. Obviously, reservations/payments to the same room/time period must be performed
atomically (mutual exclusively). If a customer tries to reserve a room that has already been taken,
then disallow this action and print a "room taken" message. If a transaction tries to operate a
non-existent room, print an error message. A customer can reserve a contiguous or non-contiguous
block of two or more rooms at the same time.
To ensure these concurrent operations yield correct results, you are to use Unix semaphores to
control access to rooms/stay periods, which are stored in shared variables.
To simulate (1) the transmission delay between the hotel's central computer and a customer's
computer, and (2) the processing of each transaction, the rst four lines in the body of each
customer specify the required total execution time (in milliseconds) for each of the three operations
performed at that customer. In your implementation, each speci ed time is the length of the critical
section for the corresponding transaction.
Valid transactions are:
reserve (room_number) begin_date number_of_days name_of_customer
cancel (room_number) begin_date number_of_days name_of_customer
reserve (room_number1,...,room_numberK) begin_date number_of_days name_of_customer
/* non-contiguous block */
cancel (room_number1,...,room_numberK) begin_date number_of_days name_of_customer
reserve (room_number1-room_numberM) begin_date number_of_days name_of_customer
/* contiguous block */
cancel (room_number1-room_numberM) begin_date number_of_days name_of_customer
check customer_name /* show rooms and stay periods reserved */
Example{reserving a non-contiguous block of rooms:
reserve (2,5,58) ...
Example{reserving a contiguous block of rooms:
reserve (8-15) ...
You can cancel a room reservation only after you have reserved it. The input is as follows:
n /* number of rooms, numbered from 1 to n */
m /* number of customers */
customer_1:
reserve reserve_time (in milliseconds)
cancel cancel_time (in milliseconds)
check check_time (in milliseconds)
:
valid operations
:
end.
:
:
customer_m:
reserve reserve_time (in milliseconds)
cancel cancel_time (in milliseconds)
check check_time (in milliseconds)
:
valid operations
:
end.
The output after completing all transactions is: a report showing the transactions and resulting
room assignments with customer names.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  i take input from getchar(); function in program in C++ 2012 Vuhelper 0 2,992 05-31-2012, 01:40 AM
Last Post: Vuhelper
  program Output in C++ 2012 Vuhelper 0 2,957 01-06-2012, 12:28 AM
Last Post: Vuhelper
  For running C++ program from command prompt “gcc” and “g++” compilers are used. Vuhelper 0 6,391 01-04-2012, 10:41 PM
Last Post: Vuhelper
  Function (Retrun push)for what purpose use in the program. ? Vuhelper 0 1,861 11-05-2011, 05:03 PM
Last Post: Vuhelper
  C++ Help with Template class program 2011 Vuhelper 0 823 07-23-2011, 05:40 PM
Last Post: Vuhelper
  A simple pthread program runtime error in c++ 2011 Vuhelper 0 898 07-23-2011, 05:39 PM
Last Post: Vuhelper
  Problem with the complexity of the program 2011 Vuhelper 0 734 07-06-2011, 06:19 PM
Last Post: Vuhelper
  Write a calculator program using a do-while loop in c++ 2011 Vuhelper 0 2,771 06-27-2011, 06:41 PM
Last Post: Vuhelper
  what is program in C++ May 2011 ? Vuhelper 0 1,898 05-30-2011, 03:00 PM
Last Post: Vuhelper
  define program in c++ May 2011 Vuhelper 0 2,086 05-29-2011, 06:11 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)