C/C++ 编程代写
当前位置:以往案例 > >os c案例 CSCI3120 operating system
2020-02-15

os c案例 In the real world, airports communicate with each other to ensure that if a flight takes off, it will be able to land shortly after it arrives. This communication is both a safety and a fuel economy measure, to avoid planes waiting a long time to land. We will add this feature to the simulator.

CSCI3120
project 4

Due: 11:59 AM, Tuesday, July 30, 2019

Introduction
In the real world, airports communicate with each other to ensure that if a flight takes off, it will be able to land shortly after it arrives. This communication is both a safety and a fuel economy measure, to avoid planes waiting a long time to land. We will add this feature to the simulator.

The purpose of this project is
Give you further experience writing multithreaded
Giveyou experience in implementing a simple asynchronous message passing IPC mech- anism
Give you experience using an IPC
To further improve your programming
In this project you will implement a simple asynchronous message passing service and use it to allow threads to communicate with each other to simulate the inter-airport com- munication.



System Requirements
This project is intended to be done and executed in a Unix environment. You can use the csci3120.cs.dal.ca Unix server, a Mac (in Terminal), or your own Unix-based system, such as Linux, OpenBSD, FreeBSD, etc. This may also work in the Cygwin environment under Windows. Note: Your code will be tested on csci3120.cs.dal.ca.


os c案例os c案例
Background
This project extends the functionality in project 3. In the real world, the airport at which the flight originates has to request permission from the destination airport before the flight takes off. This ensures that the number of planes waiting to land at an airport is kept to a minimum and that airplanes do not burn too much (or run out of) fuel.

For this project you are asked to extend your program in the following way: For each time-step T (minute)

At each airport, for all flights that are ready to depart (after their planes havebeen groomed), the airport sends requests to the corresponding desti- nation airports for permission for the flight to land at time T + 10 + length.
After all requests are sent (hint: use a barrier here), each airport receives landing requests from other
Foreach landing request the airport checks if the landing time is
Ifthe landing time is not free, then the request is
If the landing time is free, then the landing slot is assigned to the request,unless there are multiple requests for the same landing
Ifthere are multiple requests for the same free landing time, the landing time is assigned to the flight that has been waiting the longest for its request to be If two or more flights have been waiting the same amount of time, the tie is broken by the flight number. I.e., the flight with the lowest flight number is granted the request.
A response is sent for each of the requests, indicating if the request has beengranted or  (Hint: the sample solution uses two mailboxes per airport. One to recieve requests and one to receive responses to requests. This avoids some race conditions.)
Flightsthat were granted landing permission can then proceed to taxi and take-off.
Flightsthat were not granted landing permission must wait until the next time-step (minute) to make the request
The rest of the simulation is the same as in project 3.

To implement this functionality, it is recommended that a simple asynchronous message passing system be implemented (or used) to communicate between the threads. You will also need to have another list at each originating airport of flights waiting for permission to land.

Note: the sample solution to this project required an additional 80 lines of code in airport2.c and two additional source files comm.h and comm.c where the asynchronous message passing system was implemented. The latter was about 140 lines of code and implemented the following functions:

int comm_allocate() : allocate a new mailbox and returns the id of the mailbox. int comm_send(int id, void *buf) : asynchronously send a pointer to a buffer to mailbox id. (hint: the same solution passes around pointers to flight structs.

void  *  comm_recv_any(int  id) :  receive a pointer that was sent to mailboxid.
intcomm_size(int id) : return the number of messages waiting in mailbox id.
Extend your (or the provided) solution to project 3 to perform the above specified functionality.

Simulator Input
The input is the same as project 3. Please see examples as shown in the provided test suite (tests_4.zip).

Processing and Semantics
Processing rules are the same as in project 3 in addition to behaviour described above.



Expected Output
The output format is the same as project 3. Please see examples as shown in the provided test suite (tests_4.zip).



Nonfunctional Requirements
Same nonfunctional requirements as project 3. Note: the starting code is either your solution to project 3 or the sample solution, found on Brightspace.



Test Your Code!
To test your code, a test suite (tests_4.zip) is provided. Same test procedures as those in project 3 are recommended.



Hints and Suggestions
Pleasesee the hints in the background
Rememberto protect the shared data structures in you communication system with mutex locks and use condition variable to suspend threads waiting to receive a
Thesample solution to project 4 only required 80 lines of additional code added to c and additional source files comm.h and comm.c, of 140 lines of code..


The Java Option
Same conditions apply as in project 3. A penalty of 10% will be applied if the project is done in Java or C++ instead of C.



What to Hand In
You need only submit an electronic of your project. Submission must be done by 11:59 AM of the due date. Submission is done via Brightspace.

The project submission should be a single zip file (.zip) comprising the source code files that implement the simulator as well as the makefile and the runme.sh file.





Grading Scheme
The project will be graded on four criteria:

Concurrency “Is the solution maximally concurrent?”. This is determined by inspecting the code and ensuring for appropriate use of threads and locks. Concurrency is used as a multiplier for the rest of the code. Concurrency is graded on a 4 point scale:

(4) Solution is maximally concurrent e.g., uses threads appropriately and uses indi- vidual locks for each instance of a data structures.

(3) Solution is mostly concurrent e.g., uses threads appropriately but uses a single lock for all instances of a data structure.

(2) Solution is somewhat concurrent e.g., does not use threads appropriately or uses a single lock for all data structures.

(1) Solution is not very concurrent e.g., does not use threads appropriately and uses a single lock for all data structures.

(0) Solution is not concurrent.

The concurrency factor is multiplied by Functionality score because the base solution passes all tests.

Functionality “Does it work according to specifications?”. This is determined in an auto- mated fashion by running your program on a number of inputs and ensuring that the outputs match the expected outputs. The score is determined based on the number



of tests that your program passes. So, if your program passes t

tests, you will receive



that proportion of the marks.

Quality of Solution “Is it a good solution?” This considers whether the solution is correct, efficient, covers boundary conditions, does not have any obvious bugs, etc. This is determined by visual inspection of the code. Initially full marks are given to each solution and marks are deducted based on faults found in the solution.

Code Clarity “Is it well written?” This considers whether the solution is properly format- ted, well documented, and follows coding style guidelines.

If your program does not compile, it is considered non-functional and of extremely poor quality, meaning you will receive 0 for the solution.



Mark
Code Quality (Simulator)
Concurrency C = /4

Functionality (automated tests)

Code Clarity

/20


( × C)/20

/10

Total /100




Programming Guidelines

The program must read the input from the console (stdin) and must print out the resultsto the console (stdout) unless otherwise  Do not print out any output or request any input other than what is specified by the project.
Usethe file and function names specified in the
Your programs will be compiled and tested on the cs.dal.ca Unix server. In order to receive credit, your programs must compile and run on thisserver.
Yourprogram must Programs that do not compile will receive a 0.
The programs must be well commented, properly indented, and clearly written. Please see the style guidelines under projects or Resources on the course websit

在线提交订单