Giter Site home page Giter Site logo

nicelycla / sort-socket-stream Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 98 KB

Concurrent server example in c. An assignment for "Operating and Real-time systems" course

Makefile 0.78% C 99.22%
socket-server-and-client socket-stream concurrency children-programming concurrent-programming

sort-socket-stream's Introduction

SORT-socket-stream


The assignment refers to track A).
The HUB process receives a chosen number of temperatures from J sensors. For each sensor temperature, a child is created that takes care of the transmission to the hub. The hub waits for J connected processes and then the temperatures are sent to the server which takes care of forwarding them to the actuators already listening. Then, they calculate the average of the measures and the user is asked to unsubscribe the actuators.

Application launch

First launch:
$ ./hub "J" (default J = 2)
$ ./server
subsequently the actuators are registered:
$ ./attuatori "name" "(i/d)"

Tgoal and the list of sensor names will be requested iteratively. e.g .:


$ ./attuatori a1 i
Tgoal = 23
Enter 0 to stop ...
Sensor name to subscribe: t1
Sensor name to subscribe: t2
Sensor name to subscribe: 0

$ ./attuatori a2 i
Tgoal = 18
Enter 0 to stop ...
Sensor name to subscribe: t1
Sensor name to subscribe: 0


The actuators will subscribe to the server and wait for the temperatures to be subscribed.
Successively it is required to run J processes (J terminals) sensors "name" "nĀ° measures". e.g.:


$ ./sensors t1 3
$ ./sensors t2 4


Each process will send temperatures to the hub as required by the assignment. The hub will take care of the transmission to the server and the server will only forward the requested measures to the enrollment actuators.
The actuators will calculate the averages and decide accordingly whether to turn the heaters on or off.
The sensor processes end the execution by receiving the number of actuators that have subscribed to the measure. For terminate the actuators, it is required the subscription by the user.
So, one or more actuators are launched in unsubscribe mode. e.g .:


$ ./attuatori a3 d
Enter 0 to stop ...
Actuator name to unsubscribe: a1
Actuator name to unsubscribe: a2
Actuator name to unsubscribe: 0


Then, the server send an empty string to actuators and the reception will end.

sort-socket-stream's People

Contributors

nicelycla avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.