Skip to content

University project for course operating systems, Implemented ipc between 3 processes: using shared memory and fifo.

Notifications You must be signed in to change notification settings

rozek1997/ipc-linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating system course project

Task

Develop a set of producer-consumer programmes implementing the following scheme of synchronous inter-process communication:

  • Process 1: reads the data from the standard input stream and transfers it unchanged to process 2 through the K1 communication mechanism.
  • Process 2: retrieves the data sent by process 1. Converts the data received from process 1 into a hexadecimal form and transfers it to process 3 through the K2 communication mechanism.
  • Process 3: retrieves the data produced by Process 2 and outputs it to a standard diagnostic stream. The data units should be output 15 each in a single line and separated by spaces.

All three processes should be called automatically from one initiating process. When posterity processes are called, the initiating process stops working. The initiating process resumes work when the program ends (see below), its task is to "clean up" the program before it ends.

In addition, a mechanism of asynchronous transfer of information between the operator and processes and between processes should be implemented. Use the available signal mechanism for this. The operator can send to any process an end of action signal (S1), a stop of action signal (S2) and a resume of action signal (S3). The S2 signal stops synchronous data exchange between processes. The S3 signal resumes this exchange. The S1 signal terminates the operation and releases any resources used by the processes (resources are released by the parent process). Each of the signals is transmitted by the operator to only one, any process. The operator, not the programmer, decides to which process to send the signal. Each of the signals can be sent by the operator to a different process. Although the operator directs the signal to one process, the action desired by the operator must be performed by all three processes. Therefore, the process receiving the signal from the operator must notify the other two processes about the accepted request. It should therefore give them the appropriate signal, informing them of the action required by the operator. Processes receiving a signal should behave accordingly to the received signal. All three processes should react according to the operator's request. Signals marked in the task description with S1 S3 symbols should be selected independently from those available in the system (e.g. SIGUSR1, SIGUSR2, SIGINT, SIGCONT). Communication mechanisms: K1 and K2 are given in the file list_mechanizmow.pdf - each student has different communication mechanisms assigned. Some communication mechanisms require the use of synchronization mechanisms, such as semaphores.

The program is supposed to enable the launch:

  • in interactive mode - the operator enters data from the keyboard,
  • in the mode of reading data from a specific file,
  • in the /dev/urandom read mode.

Additional information: For evaluation 5 (bdb) - sending signals to processes should be done using an additional program written in C language. This program should allow (using the user menu) to select the signal and the process to which the signal is to be sent.

View

Project app

project_app

Client app

client app

Compilation

* With gcc * compile project application
        Inside app folder:
        gcc -o main *.c
    
  • Compile client application
    Inside client folder
    gcc -o client client.c
    
  • with cmake
    • Compile project application
            mkdir build && cd build
            cmake .. 
            make so_app
      
    • Compile project application
          > mkdir build && cd build 
            cmake .. 
            make so_client
      

Launch program with mode

  • -i - interactive mode
  • -u - /dev/urandom read mode
  • -f [filepath] - specific file reading mode
Example project application
>>./main -f /dev/urandom

Example client application

./client 

Communication between processes

  • Between P1 and P2 - shared memory and synchronized with 2 semaphore
  • Betwenn P2 and P3 - fifo

Signal used

  • SIGINT - for stop communication between 3 processes
  • SIGTSTP - for suspending communication
  • SIGCONT - for resuming communication

About

University project for course operating systems, Implemented ipc between 3 processes: using shared memory and fifo.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published