Fwd: eXpOs stage 22 assignment 2

65 views
Skip to first unread message

Murali Krishnan

unread,
Oct 25, 2020, 12:33:53 PM10/25/20
to xos-...@googlegroups.com


---------- Forwarded message ---------
From: senan jude <senan_b...@nitc.ac.in>
Date: Sun, Oct 25, 2020 at 8:40 PM
Subject: Re: eXpOs stage 22 assignment 2
To: Murali Krishnan <kmu...@nitc.ac.in>


Sorry sir I'll send it now

On Sat, Oct 24, 2020, 7:57 PM Murali Krishnan <kmu...@nitc.ac.in> wrote:
Attachment missing.   

On Sat, Oct 24, 2020 at 7:21 PM senan jude <senan_b...@nitc.ac.in> wrote:
Sir
      In the assignment 2 of stage 22 the parent program (attached below) is supposed to print the pid of the 8 resulting process of 3 consecutive fork system calls. But as I run the code half of the pid values were 0. When I checked the code the return value of fork system call is printed by each process. But this value is not the pid. In the last fork call the existing 4 process are made in to 8 and those former 4 process have pid of child as return value, and the new 4 process has the value 0. So should I change the provided code? Thanking you in advance.

Sincerely
Senan Jude
B180706CS
CSE B
IMG_20201025_203948.jpg
IMG_20201025_203857.jpg

Karunakaran Murali Krishnan

unread,
Oct 25, 2020, 10:04:03 PM10/25/20
to xos-...@googlegroups.com

Sir
      In the assignment 2 of stage 22 the parent program (attached below) is supposed to print the pid of the 8 resulting process of 3 consecutive fork system calls. But as I run the code half of the pid values were 0. When I checked the code the return value of fork system call is printed by each process. But this value is not the pid. In the last fork call the existing 4 process are made in to 8 and those former 4 process have pid of child as return value, and the new 4 process has the value 0. So should I change the provided code? Thanking you in advance.


Could you please run xsm with xsm --timer=2 (or timer =3) - basically small values. 
A better way is;  before return 0.  /* exit from process */  Put a while loop (say something like  i=1 to 500 do a=1;)  in each processes. 
The issue probability with your program is that the processes exit very quickly and hence the process table entries get free quickly.
Hence, by the time new processes are created, the same PID is given (because the process with the PID had already finished). 
When you put a large loop  within each process before they exit after the child is created, new new PID-s will have to be allocated for newly created process,
as the parent has not released the PID. 
As with some previous question raised here, if this doesn't fix the problem, then your OS code has some issues.
Murali

--
You received this message because you are subscribed to the Google Groups "XOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xos-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/xos-users/CAEp%2Bu%2ByYrXM3faim9V%3DAwjHUJBAYp1kT%3DiTD-7a_aV_zcOnr_w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages