OS
Operating
Systems
and
Real
Time
Operating
Systems

General information


Threads, Inter Process Communication

This session is dedicated to threads and to the communication between threads and processes.

You don't have to submit source files or reports for this sessions. For this session, you will need to log into a PC running Linux. If you are at Eurecom, simply log on a PC of rooms 52.

I. Why using threads?

  1. Open the slides on Threads

  2. Watch the video on an introduction to threads



II. Example of multithreading

  1. Open the slides on Threads

  2. Watch the video on examples of threading models




III. Inter process / thread communication

  1. Open the slides Threads, last section

  2. Watch the video on IPC

  3. I often say that this is very important to test the return values of functions. In the code of the signal sender, I test the return value of the syscall "kill". Using manual pages, find at least three cases for which "-1" is returned by "kill".
  4. (Help me!) $ man -s2 kill
    On my GNU/Linux computer, I can notice three errors:
    1. An invalid signal was specified
    2. The process does not have permission to send the signal to any of the target processes
    3. The process or process group does not exist


  5. Complete/adapt the following short C program to show three different errors of "kill()".
  6. #include <stdio.h>
    #include <sys/types.h>
    #include <signal.h>
    #include <errno.h>
    
    int main(int arg, char** argv) {
    
      // We assume here that "9278" is a valid process id
      if (kill(9278, 192) == -1) {
        printf("Invalid kill. errno=%d\n", errno);
        if (errno == EINVAL) {
          printf("Success for error EINVAL\n");
        }
      }
    }
    

  7. Simlarly, what are the possible errors for the "signal()" syscall?


IV. Discovery of Android

Now, continue on the discovery of the Android Operating system: kernel management, handling of processes, I/O, etc.