IT LAB - 1: MINOR EXAMINATION

50 Marks (5 x 10)


I N S T R U C T I O N S


  1. Create one process (P1) with four children (C1 - C4). C1 prints the numbers 1 - 1000, C2 prints 1001 - 2000, C3 prints 2001 - 3000 and C4, 3001 - 4000. The job of the parent is to make sure that the numbers are printed in correct ascending order and finally print the numbers 4001 - 5000. You cannot use mutexes, condition variables, semaphores and signals.
  2. Do the same problem as above but with threads. In other words, there is a parent process P1 which has four threads T1 - T4 that take the functions of the four children C1 - C4 above. Again, do not use any synchronisation primitives or signals.
  3. Write a program in file count.c to read stdin line by line and output the number of lines on stdout. Compile it into an executable called count.Write another program using popen() to read a file and send it through the pipe to the count which outputs the number of lines in the file. Test it by counting the number of lines in count.c.
  4. Do the Problem 1 above using named semaphores for synchronization. Each process P1, C1, C2, C3 and C4 are written as separate executable programs. They are started in separate windows in any order, i.e., you may open a window and execute C4 first; then open another window and execute P1; and so on.
  5. Do the Problem 2 above using any synchronisation primitive of your choice. That is, synchronize between multiple threads.