inter/docs/PROJECT.md
2024-10-13 21:03:31 +03:00

1.8 KiB

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

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 between 0-19 (random number generation or simply hardcoded)
  • P1-P4 should send the random integer 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 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)

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)