Академический Документы
Профессиональный Документы
Культура Документы
Activity 1
1. Write down a 3 line explanation of following command of linux ps 2. Write a small piece of code that run and infinite loop printing Test. Compile and run it and keep it running while doing step 3 3. Use ps command to locate the id and status of your program you have started executing in step 2 4. Find what is Zombie in linux 5. Adjust the sleep calls for parent and child and use ps to answer these questions What status is being printed when the child terminates before the parent, but the parent does not? What is the parent process id (PPID) of a child process whose parent terminates before the child? To make the parent wait for the child, replace the sleep() by pid = waitpid(pid,&status, 0) in the code. Here status is an integer. For the parent and read about the function by executing man 2 wait.
Activity 2
I hope all of you are aware of merge sort. Lets assume you are given the task to display the mobile company records of their customers calls in sorted order. The company CEO is interested in getting the records in following form
One f the inefficient solution is to write down the code in one single process to sort the records using merge sort. However, when this process is written down, the output time is huge which irritates the CEO. He has assigned you the task to write an efficient code so that he can get the results in order of few seconds. You can assume that the records are stored in the file in following format CustomerID, Call Date, Calling Network You can further assume that the calling network attribute in the above line can have two possible values only. If it is 0, it means the call was made to the same network. If it is 1, the call was made to the other network. You have to use the merge sort to sort the records by date. Perform first two levels of merge sort in separate processes. When records have been sorted, create another process that can print the records in the format CEO likes (as shown in the table above) Example: Lets say there are 100,000 records in the file. Merge sort divides the records into half in the first step, so will you do with the records. First 50,000 records will be sorted by process1. Other 50,000 records will be sorted by process 2.
Display Information
Sort Records