@kamaskshi: The order of execution of the processes cant be in user hands.It is a scheduling aspect.So we cant expect the peculiar order.
On 8 August 2011 22:10, Kamakshii Aggarwal <[email protected]> wrote: > @sagar: i think order has to be fixed...in amazon they gave us four > options.... > but i dnt remember them now... > > > On Mon, Aug 8, 2011 at 10:05 PM, aditi garg <[email protected]>wrote: > >> @sagar thanx :) >> >> >> On Mon, Aug 8, 2011 at 9:01 PM, sagar pareek <[email protected]>wrote: >> >>> @aditi >>> nope... it will run in parallel...so order is not fix.... >>> >>> >>> On Mon, Aug 8, 2011 at 8:48 PM, Pradeep Mishra <[email protected] >>> > wrote: >>> >>>> no it'll vary as the PID will vary from parent to child. >>>> >>>> >>>> >>>> On Mon, Aug 8, 2011 at 8:05 AM, aditi garg >>>> <[email protected]>wrote: >>>> >>>>> i was asking about the order in printf....so it wud be like 8times one >>>>> and then 8 times two? >>>>> >>>>> >>>>> On Mon, Aug 8, 2011 at 8:23 PM, sagar pareek <[email protected]>wrote: >>>>> >>>>>> >>>>>> >>>>>> M >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> >>>>>> / \ >>>>>> M >>>>>> C1 >>>>>> / \ >>>>>> / \ >>>>>> / >>>>>> \ / \ >>>>>> / >>>>>> \ / \ >>>>>> >>>>>> / \ >>>>>> / \ >>>>>> M >>>>>> C2 C1 C3 >>>>>> / \ >>>>>> / \ / \ / >>>>>> \ >>>>>> / \ >>>>>> / \ / \ >>>>>> / \ >>>>>> M C4 >>>>>> C2 C5 C1 C6 C3 C7 >>>>>> / \ / \ / >>>>>> \ / \ / \ / \ / >>>>>> \ / \ >>>>>> M C8 C4 C9 C2 C10 C5 C11 C1 >>>>>> C12 C6 C13 C4 C14 C7 C15 >>>>>> >>>>>> >>>>>> M C4 C2 C5 C1 C6 C3 C7 (one level upper will have ret>0 and rest >>>>>> will have ret =0 >>>>>> >>>>>> Just think ur self how any process and its child have pid==0 ??? >>>>>> >>>>>> >>>>>> I hope its clear now... >>>>>> >>>>>> >>>>>> On Mon, Aug 8, 2011 at 8:05 PM, aditi garg <[email protected] >>>>>> > wrote: >>>>>> >>>>>>> @ sagar: wat wud be the order? as in all 8 frst wud return non zero >>>>>>> and rest 0 or wat? >>>>>>> >>>>>>> >>>>>>> On Mon, Aug 8, 2011 at 6:50 PM, Kamakshii Aggarwal < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> ok ..thanks sagar..:) >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Aug 8, 2011 at 6:42 PM, sagar pareek <[email protected] >>>>>>>> > wrote: >>>>>>>> >>>>>>>>> lets label your forks :- >>>>>>>>> main() >>>>>>>>> { >>>>>>>>> int ret; >>>>>>>>> ret=fork(); ------ 1 >>>>>>>>> ret=fork(); ------ 2 >>>>>>>>> ret=fork(); ------- 3 >>>>>>>>> ret=fork(); ------- 4 >>>>>>>>> >>>>>>>>> if(!ret) >>>>>>>>> printf("one"); >>>>>>>>> else >>>>>>>>> printf("two"); >>>>>>>>> } >>>>>>>>> >>>>>>>>> Now >>>>>>>>> original main() is suppose named M >>>>>>>>> then after encountering fork() 1st then >>>>>>>>> >>>>>>>>> >>>>>>>>> M >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> M C1 >>>>>>>>> >>>>>>>>> >>>>>>>>> now after fork() -2 >>>>>>>>> >>>>>>>>> >>>>>>>>> M >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> / \ >>>>>>>>> >>>>>>>>> M C1 >>>>>>>>> >>>>>>>>> / \ / \ >>>>>>>>> >>>>>>>>> M C2 C1 C3 >>>>>>>>> >>>>>>>>> >>>>>>>>> after fork()- 4 >>>>>>>>> >>>>>>>>> it will be >>>>>>>>> >>>>>>>>> M C1 C2 C3 ...... C15 >>>>>>>>> now we have half of them include main() have >>>>>>>>> ret!=0 and rest of them ret=0 >>>>>>>>> >>>>>>>>> i hope its clear now... >>>>>>>>> >>>>>>>>> >>>>>>>>> On Mon, Aug 8, 2011 at 12:53 PM, Shachindra A C < >>>>>>>>> [email protected]> wrote: >>>>>>>>> >>>>>>>>>> At the point of execution of the 4th fork(), there are 8 processes >>>>>>>>>> i.e, the 4th fork will get executed 8 times. The final value of ret >>>>>>>>>> will >>>>>>>>>> depend on this fork. the fork will return 0 in the 8 child processes >>>>>>>>>> created >>>>>>>>>> and returns pid of the child in the parent processes. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Mon, Aug 8, 2011 at 12:49 PM, Kamakshii Aggarwal < >>>>>>>>>> [email protected]> wrote: >>>>>>>>>> >>>>>>>>>>> then please elaborate? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Mon, Aug 8, 2011 at 12:34 PM, Pradex < >>>>>>>>>>> [email protected]> wrote: >>>>>>>>>>> >>>>>>>>>>>> get it..!! :) :) >>>>>>>>>>>> >>>>>>>>>>>> On Aug 7, 10:49 pm, Shachindra A C <[email protected]> >>>>>>>>>>>> wrote: >>>>>>>>>>>> > 8 one's and 8 two's. The order in which they get printed might >>>>>>>>>>>> vary. >>>>>>>>>>>> > >>>>>>>>>>>> > On Mon, Aug 8, 2011 at 11:11 AM, Kamakshii Aggarwal >>>>>>>>>>>> > <[email protected]>wrote: >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > > what will be the o/p of the following program: >>>>>>>>>>>> > >>>>>>>>>>>> > > main() >>>>>>>>>>>> > > { >>>>>>>>>>>> > > int ret; >>>>>>>>>>>> > > ret=fork(); >>>>>>>>>>>> > > ret=fork(); >>>>>>>>>>>> > > ret=fork(); >>>>>>>>>>>> > > ret=fork(); >>>>>>>>>>>> > >>>>>>>>>>>> > > if(!ret) >>>>>>>>>>>> > > printf("one"); >>>>>>>>>>>> > > else >>>>>>>>>>>> > > printf("two"); >>>>>>>>>>>> > > } >>>>>>>>>>>> > >>>>>>>>>>>> > > -- >>>>>>>>>>>> > > Regards, >>>>>>>>>>>> > > Kamakshi >>>>>>>>>>>> > > [email protected] >>>>>>>>>>>> > >>>>>>>>>>>> > > -- >>>>>>>>>>>> > > You received this message because you are subscribed to the >>>>>>>>>>>> Google Groups >>>>>>>>>>>> > > "Algorithm Geeks" group. >>>>>>>>>>>> > > To post to this group, send email to >>>>>>>>>>>> [email protected]. >>>>>>>>>>>> > > To unsubscribe from this group, send email to >>>>>>>>>>>> > > [email protected]. >>>>>>>>>>>> > > For more options, visit this group at >>>>>>>>>>>> > >http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>>>> > >>>>>>>>>>>> > -- >>>>>>>>>>>> > Regards, >>>>>>>>>>>> > Shachindra A C >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> You received this message because you are subscribed to the >>>>>>>>>>>> Google Groups "Algorithm Geeks" group. >>>>>>>>>>>> To post to this group, send email to [email protected] >>>>>>>>>>>> . >>>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>>> [email protected]. >>>>>>>>>>>> For more options, visit this group at >>>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> Regards, >>>>>>>>>>> Kamakshi >>>>>>>>>>> [email protected] >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> You received this message because you are subscribed to the >>>>>>>>>>> Google Groups "Algorithm Geeks" group. >>>>>>>>>>> To post to this group, send email to [email protected]. >>>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>>> [email protected]. >>>>>>>>>>> For more options, visit this group at >>>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Regards, >>>>>>>>>> Shachindra A C >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>>> Groups "Algorithm Geeks" group. >>>>>>>>>> To post to this group, send email to [email protected]. >>>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>>> [email protected]. >>>>>>>>>> For more options, visit this group at >>>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> **Regards >>>>>>>>> SAGAR PAREEK >>>>>>>>> COMPUTER SCIENCE AND ENGINEERING >>>>>>>>> NIT ALLAHABAD >>>>>>>>> >>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "Algorithm Geeks" group. >>>>>>>>> To post to this group, send email to [email protected]. >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> [email protected]. >>>>>>>>> For more options, visit this group at >>>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Regards, >>>>>>>> Kamakshi >>>>>>>> [email protected] >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Algorithm Geeks" group. >>>>>>>> To post to this group, send email to [email protected]. >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> [email protected]. >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Aditi Garg >>>>>>> Undergraduate Student >>>>>>> Electronics & Communication Divison >>>>>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY >>>>>>> Sector 3, Dwarka >>>>>>> New Delhi >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Algorithm Geeks" group. >>>>>>> To post to this group, send email to [email protected]. >>>>>>> To unsubscribe from this group, send email to >>>>>>> [email protected]. >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> **Regards >>>>>> SAGAR PAREEK >>>>>> COMPUTER SCIENCE AND ENGINEERING >>>>>> NIT ALLAHABAD >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Algorithm Geeks" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Aditi Garg >>>>> Undergraduate Student >>>>> Electronics & Communication Divison >>>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY >>>>> Sector 3, Dwarka >>>>> New Delhi >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> Pradeep Kumar Mishra >>>> IIIT Allahabad >>>> B. Tech 2nd Year ( IT ) >>>> [email protected] >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> **Regards >>> SAGAR PAREEK >>> COMPUTER SCIENCE AND ENGINEERING >>> NIT ALLAHABAD >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Aditi Garg >> Undergraduate Student >> Electronics & Communication Divison >> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY >> Sector 3, Dwarka >> New Delhi >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Regards, > Kamakshi > [email protected] > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, [email protected] 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
