inter/docs/PROJECT.md

35 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2024-10-13 18:34:28 +02:00
## 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)
2024-10-13 20:03:31 +02:00
- P1-P4: Process should generate a random integer between 0-19 (random number generation or simply hardcoded)
- P1-P4 should send the random integer to init through message passing (`pipe` syscall)
2024-10-13 18:34:28 +02:00
- Init should read data sent by P1-P4
**Criteria 2:**
2024-10-13 20:03:31 +02:00
- Scheduler is an independent process: it should create a shared memory segment (`shmget` and related syscalls)
- Scheduler should read data (a list of random numbers) written by init, sort the list in ascending order, and print the list (sorting algorithm of choice)
2024-10-13 18:34:28 +02:00
**Criteria 3:**
- Init should attach to the shared memory created by the scheduler process (`shmat` and related syscalls, any unique key of choice -> `ftok` syscall is a clean way to accomplish this)
2024-10-13 18:34:28 +02:00
- 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)