Comments (5)
Using 'fflush(stdout);' solved this:
Unable to access data from the 'msg_recv_atc'.
The issue previously might be caused because of buffering. The standard output might be buffered, and the buffer might not be flushed before the program exits or enters the next iteration of the loop.
from os-assignment-2.
In the commit "2f26369", whenever a msg will appear in the msg queue from the ATC, a new thread is being created and a suitable runway is being found out. If there is no suitable runway, backup runway is assigned.
Also,
Have to confirm the method of using 'val' in line 136.
is solved.
from os-assignment-2.
The following part:
Not sure about the usage of mutex. In the current code, lock is used only during the boarding/deboarding and takeoff/landing delays(sleep(2) and sleep(3)). What about the condition that no other plane should be given a runway when it is allotted another plane.
can be solved by using a 'runway_mutex'. This should allow a runway in an airport to be used by only one thread until the following are completed:
For Departure Airport:
- boarding/loading time(3sec)
- takeoff time(2sec)
- send msg to ATC through msg queue
For Arrival Airport:
- Plane travel time(30 sec) after receiving signal from the ATC
- landing time(2sec)
- deboarding/unloading time(3sec)
- send signal to ATC through msg queue
from os-assignment-2.
The commit 'eb0daeb' has improved this issue. An array of locks 'runway_mutex' is used. So each runway will have its own lock. If a runway is selected by a thread, it cannot be accessed by another thread unless the former exits. But at the same time this might lead to lack of security to shared resources. So, we should check what are the shared resources which get affected.
Also, there is some abnormal behavior when multiple planes try to depart/arrive at same airports. Data is getting corrupted in this case as there is no protection to shared resources.
from os-assignment-2.
Since the basic questions of this issue have been solved, this is being closed. The solution to the synchronization and abnormal results issue will be addressed in another issue or discussion.
from os-assignment-2.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from os-assignment-2.