The Open Source Swiss Army Knife

/code/c/unix_c/fork/
/code/c/unix_c/fork/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /code   /c   /unix_c   /fork 
Permalink: /var/sirfsup/code/c/unix_c/fork/old_logfile.html
Title: add
article options : please login   |  print view

Process Ring Simulator Log for joe speigle generated Tue Mar 09 20:04:24 GMT 2004

Process Ring Simulator Log for joe speigle generated Tue Mar 09 20:04:24 GMT 2004

  1. code: code for the program
  2. one: default configuration
  3. two: Change After fork from parent to child
  4. three: Change After fork from parent to either
  5. four: Change After fork from parent to random
  6. five: Change Choose Process from FCFS to Random
  7. six: Change Scheduling from no preempt to round robin with a quantum of 5 and Choose Process from FCFS to Random
  8. seven: Repeat the experiment above with a quantum of 2 and see if it behaves differently
  9. eight: Change Print Atomic to Print Not Atomic with probability 0.1
  10. nine: Insert a wait(NULL) call before the fprintf statement
  11. ten: Change Print Atomic to Print Not Atomic with probability 0.1 and insert a wait(NULL) call before the fprintf statement

code

pipe(fd);
dup2(fd[0],0);
dup2(fd[1],1);
close(fd[0]);
close(fd[1]);
for(i=1;i<nprocs;i++) {
   pipe(fd);
   if (childpid = fork()) {
      dup2(fd[1],1);
   }
   else {
      dup2(fd[0],0);
   }
   close(fd[0]);
   close(fd[1]);
   if (childpid)
      break;
}
fprintf(stderr,"This is process %d with parent %d\n",getpid(),getppid());
-->



Ring of Processes Simulation

default configuration

Tue Mar 09 20:05:07 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1

Change After fork from parent to child

Tue Mar 09 20:12:08 GMT 2004


Gantt Chart
Tue Mar 09 20:11:33 GMT 2004


Output for Ring of Processes
After fork: child, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1


Output for Ring of Processes
After fork: child, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1


Output for Ring of Processes
After fork: child, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1

Change After fork from parent to either


Output for Ring of Processes
After fork: either, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 104 with parent 103
This is process 102 with parent 1
This is process 103 with parent 1


Output for Ring of Processes
After fork: either, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 102 with parent 101
This is process 101 with parent 1
This is process 104 with parent 103
This is process 103 with parent 1


Output for Ring of Processes
After fork: either, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 102 with parent 101
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 104 with parent 103
This is process 103 with parent 1

change after fork from parent to random



Gantt Chart


Output for Ring of Processes
After fork: random, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 104 with parent 103
This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1


Output for Ring of Processes
After fork: random, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: random, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1

Change Choose Process from FCFS to Random

Tue Mar 09 21:11:32 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: no preempt, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1

Change Scheduling from no preempt to round robin with a quantum of 5 and Choose Process from FCFS to Random

Tue Mar 09 20:36:28 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 5, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 5, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 5, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1

Repeat the experiment above with a quantum of 2 and see if it behaves differently

Tue Mar 09 20:41:08 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 2, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 102
This is process 104 with parent 103


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 2, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1


Output for Ring of Processes
After fork: parent, Choose Process: Random, Scheduling: RR quantum 2, Print Atomic
This is process 100 with parent 1
>>>This is process 101 with parent 1
This is process 102 with parent 1
This is process 103 with parent 1
This is process 104 with parent 1

Change Print Atomic to Print Not Atomic with probability 0.1.

Tue Mar 09 20:47:20 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
TThis is process 101 his is process 100 wiTwith pareth parent 1
>>>This is process 103his nt 100
Thi with parent 102
iss is process 104 with parent 1 process 102 03
with parent 101
Tue Mar 09 20:48:16 GMT 2004


Gantt Chart


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
This is process 100 with parThis is procesent 1
>>>ThThis is101 This is process 104 with parent 103is is proc with parent 100
ess 103 with parent 102
process 102 with parent 101


Output for Ring of Processes
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
This iTs processThis ish 100This is process 103 with pris is process 101  witThis  parocwih parent is procentess 102 with parent 101
th parent 100
1
>>>ess 104  102
with parent 103

Insert a wait(NULL) call before the fprintf statement

>>>
pipe(fd);
dup2(fd[0],0);
dup2(fd[1],1);
close(fd[0]);
close(fd[1]);
for(i=1;i<nprocs;i++) {
   pipe(fd);
   if (childpid = fork()) {
      dup2(fd[1],1);
   }
   else {
      dup2(fd[0],0);
   }
   close(fd[0]);
   close(fd[1]);
   if (childpid)
      break;
}
wait(NULL);
fprintf(stderr,"This is process %d with parent %d\n",getpid(),getppid());
-->
Tue Mar 09 20:52:01 GMT 2004


Gantt Chart


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 103 with parent 102
This is process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1
>>>


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 103 with parent 102
This is process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1
>>>


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Atomic
This is process 104 with parent 103
This is process 103 with parent 102
This is process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1

Change Print Atomic to Print Not Atomic with probability 0.1 and insert a wait(NULL) call before the fprintf statement.

Tue Mar 09 20:57:41 GMT 2004


Gantt Chart


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
This is process 104 with parent 103
This is process 103 with parent 102
This is process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1
>>>


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
This is process 104 with parent 103
This is process 103 with parent 102
This is process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1
>>>


Output for Ring of Processes (modified)
After fork: parent, Choose Process: FCFS, Scheduling: no preempt, Print Not Atomic 0.1
This is process 104 with parent 103
This is process 103 with parent 102
Thiis process 102 with parent 101
This is process 101 with parent 100
This is process 100 with parent 1
>>>

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top