Of Co mputer & Emerg ing Sciences-Isla ma ba d
Operating Systems
Spring 2012 Lab-Assignment2 Deadline: Tuesday 13th March, 2012 12:00 PM
GENERAL INSTRUCTIONS: Programming can be done in either C or C++. Submissions should include the annotated source code. Programs that will not be executed will get a low grade. Make sure your programs do not crash when given bad input, but instead provide warning messages Copy cases will get NEGATIVE MARKS
SUBMISSION INSTRUCTIONS The compressed files (either rar or zip) are required to be submitted using SLATE in a timely manner. Submission Folder name should be Roll No_Sec e.g. 11i-1111_A Marks will be deducted in case of late submissions.
Q.1 Write a program that uses fork () to create one child process named CHILD. Using pipe(), establish a pipe between parent and child. Using dup2(), attach file descriptors for Standard input and Standard output to the pipe. Parent takes data from the keyboard and adds a suffix "-PARENT-PROCESSED" to the data. Then parent passes the stamped data to child through pipe. Child marks "-CHILD-PROCESSED" at the end of string and prints the processed data on Standard output. Above processes will be terminated with the input of EXIT. [10]
Q.2 Write a program that computes the square roots of the integers from 0 to 99 in a separate thread and returns an array of doubles containing the results. In the meantime the main thread should display a short message to the user and then display the results of the computation when they are ready. [5]
Q.3 Write a program that counts the Ctrl+C Signals hit by the user using standard input. When counter reaches to 5, the program shall ask user whether he/she really wants to exit, if user selects “yes”, program should be terminated. Otherwise it should reset the counter. Moreover, if user presses key combination of Ctrl+Z or Ctrl+\ then respective signal number should be displayed. Make sure not to entertain any