docs: demo description

This commit is contained in:
ae 2024-10-13 19:34:28 +03:00
parent 4a8e59afd7
commit b225bbbad9
Signed by: ae
GPG Key ID: 995EFD5C1B532B3E
3 changed files with 34 additions and 3 deletions

View File

@ -1,3 +0,0 @@
# inter
Simple inter-process communication demo

34
docs/PROJECT.md Normal file
View File

@ -0,0 +1,34 @@
## Inter-process communication between two processes
### System overview
| Process | Description |
| ----------- | ------------------------------------------------------------------------------------------------- |
| `init` | Forks 4 child processes, reads data from them, and writes that data to the shared memory |
| `P1-P4` | Generates random priority number (in the range 0-19) and sends that priority number to the parent |
| `scheduler` | Creates the shared memory segment, reads data written into it, and prints that data |
![Project system overview](./media/system-overview.png)
### Implementation criteria
**Criteria 1:**
- Init is a parent process, which forks child processes P1-P4 (`fork` syscall)
- P1-P4: Process should generate a random integer number between 0-19 (random number generation or simply hardcoded)
- P1-P4 should send the random number to init through message passing (`pipe` syscall)
- Init should read data sent by P1-P4
**Criteria 2:**
- Scheduler is an independent process: it should create a shared memory segmnet (`shmget` and related syscalls)
- Scheduler should read dadta (a list of random numbers) written by init, sort the list in ascending order, and print the list (sorting algorithm of choice)
**Criteria 3:**
- Init should attach to the shared memory created by the scheduler process (`shmat` and related syscalls, hardcoded to any unique key of choice -> `ftok` syscall is a clean way to accomplish this)
- Init should write random numbers from P1-P4 into the shared memory
**Termination:**
- After scheduler prints the data, init should detach from shared memory and scheduler should detach and delete the shared memory segment (`schmdt` and `shmctl` syscalls)

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB