BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | CSCI3120 Assignment 4

C语言代写 | CSCI3120 Assignment 4

CSCI3120 A4的主要内容是在A3的基础上继续完善代码模拟C语言通信机制实现

Introduction
CSCI3120 Assignment 4
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 assignment is
1. Give you further experience writing multithreaded applications.
2. GiveyouexperienceinimplementingasimpleasynchronousmessagepassingIPCmech-
anism
3. Give you experience using an IPC mechanism.
4. To further improve your programming skills.
In this assignment 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 assignment 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.
Background
This assignment extends the functionality in Assignment 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 assignment you are asked to extend your program in the following way: For each time-step T (minute)
1. At each airport, for all flights that are ready to depart (after their planes have been groomed), the airport sends requests to the corresponding desti- nation airports for permission for the flight to land a time T + 10 + length time.
1

CSCI3120 Summer 2019 Assignment 4
2. After all requests are sent (hint: use a barrier here), each airport receives landing requests from other airports.
3. For each landing request the airport checks if the landing time is free.
(a) If the landing time is not free, then the request is denied.
(b) If the landing time is free, then the landing slot is assigned to the
request, unless there are multiple requests for the same landing time.
(c) If there 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 satisfied. 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.
4. A response is sent for each of the requests, indicating if the request has been granted or denied.
5. Flights that were granted landing permission can then proceed to taxi and take-off.
6. Flight that were not granted landing permission must wait until the next time-step (minute) to make the request again.
The rest of the simulation is the same as in Assignment 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 assignment 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 from, int to, void *buf) : asynchronously send a pointer to a buffer to mailbox to from mailbox from. (hint: the same solution passes around
pointers to flight structs.
• void * comm_recv_any(int id) : receive a pointer that was sent to mailbox id.
• int comm_size(int id) : return the number of messages waiting in mailbox id.
Extend your (or the provided) solution to Assignment 3 to perform the above specified functionality.
Simulator Input
The input is the same as Assignment 3. Please see examples as shown in the provided test suite (tests_4.zip).
2

CSCI3120 Summer 2019 Assignment 4 Processing and Semantics
Processing rules are the same as in Assignment 3 in addition to behaviour described above.
Expected Output
The output format is the same as Assignment 3. Please see examples as shown in the provided test suite (tests_4.zip).
Nonfunctional Requirements
Same nonfunctional requirements as Assignment 3. Note: the starting code is either your solution to Assignment 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 Assignment 3 are recommended.
Hints and Suggestions
1. Please see the hints in the background section.
2. Remember to protect the shared data structures in you communication system with
mutex locks and use condition variable to suspend threads waiting to receive a message.
3. The sample solution to Assignment 4 only required 80 lines of additional code added
to airport2.c and additional source files comm.h and comm.c, of 140 lines of code..
The Java Option
Same conditions apply as in Assignment 3. A penalty of 10% will be applied if the assignment is done in Java or C++ instead of C.
What to Hand In
You need only submit an electronic of your assignment. Submission must be done by 11:59 AM of the due date. Submission is done via Brightspace.
The assignment 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.
3

CSCI3120 Summer 2019 Assignment 4 Grading Scheme
The assignment 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 T
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
4

CSCI3120 Summer 2019 Assignment 4 Programming Guidelines
1. The program must read the input from the console (stdin) and must print out the results to the console (stdout) unless otherwise specified. Do not print out any output or request any input other than what is specified by the assignment.
2. Use the file and function names specified in the assignment.
3. Your programs will be compiled and tested on the csci3120.cs.dal.ca Unix server.
In order to receive credit, your programs must compile and run on this server.
4. Your program must compile. Programs that do not compile will receive a 0.
5. The programs must be well commented, properly indented, and clearly written. Please
see the style guidelines under Assignments or Resources on the course website.
5

bestdaixie