diff --git a/README.md b/README.md deleted file mode 100644 index 8fec84d..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# inter - -Simple inter-process communication demo \ No newline at end of file diff --git a/docs/PROJECT.md b/docs/PROJECT.md new file mode 100644 index 0000000..138126e --- /dev/null +++ b/docs/PROJECT.md @@ -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) diff --git a/docs/media/system-overview.png b/docs/media/system-overview.png new file mode 100644 index 0000000..f854d5c Binary files /dev/null and b/docs/media/system-overview.png differ