Spring08_Homework1PartB_Solutions

Spring08_Homework1PartB_Solutions - Homework 1B ICS143,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 1B ICS-143, Spring 2008 * Start Early. * Do not hesitate to ask questions. * If you make any assumptions, state them and be brief in your answers. * Hand in your homework to the distribution center before the following due date/time. Part B (65 points): Due 5/2/2008, 4:00pm Question 1 [Chapter 3, 4: 10 points] 1a.  To answer this question you need to do some research on system calls in  Unix.  A Fork system call in Unix is used to create a new process, consider the  following code: (10 points) a)  What will be the output of the program? Solution: PPPPP b)  Change the code such that the output of the program will become only 
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
one 'P'. Solution: printf statement should be before fork() statement as follow.  If(child_pid != 0)                   Printf(“P”);  Or you can replace printf() with the following.           If(child_pid != 0)                   Printf(“P”);  There may also be more ways to do this.  Question 2[Chapter 5, 6: 55 points] 2a.  Show the process flow graph of the following expressions (5 points) ('body'  represents the code the process would normally execute): a)  p1: body; V(mut_a); V(mut_b); V(mut_c); p2: P(mut_c); body; p3: P(mut_a); body; V(mut_d); p4: P(mut_d); body; V(mut_e); V(mut_e); p5: P(mut_b); body; V(mut_f); V(mut_f); p6: P(mut_e); P(mut_f); body; p7: P(mut_e); P(mut_f); body; Solution:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/18/2009 for the course CSE 104 taught by Professor Franklin,s during the Spring '08 term at UC Irvine.

Page1 / 9

Spring08_Homework1PartB_Solutions - Homework 1B ICS143,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online