It's UWAweek 38 (2nd semester, week 8)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying the 12 articles in this topic
Showing 12 of 1934 articles.
Currently 25 other people reading this forum.


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful
11:35am Tue 27th Aug, ANONYMOUS

void function(void) { fork(); fork(); printf("hello world\n"); } this function will produce 4 line of "hello world" when been executed; why the answer to this question is D?


SVG not supported

Login to reply

👍?
helpful
7:17pm Tue 27th Aug, Shayan R.

Maybe it's a trick question because we don't know if function() is actually called. Then again, I didn't write it.


SVG not supported

Login to reply

👍?
helpful
5:06am Wed 28th Aug, Christopher M.

ANONYMOUS wrote:
> this function will produce 4 line of "hello world" when been executed;
Will it? In all cases? There are no trick questions in the tests.


SVG not supported

Login to reply

👍?
helpful
3:40pm Wed 28th Aug, ANONYMOUS

I have tried that code many times and get the same output which indicates that c is the correct answer. what is 'cases' means by you? are you talking about the different OS?


SVG not supported

Login to reply

👍?
helpful
4:00pm Wed 28th Aug, David C.

I think one of the cases was that the RAM is full and no more programs can be loaded into memory, which would result in less than 4 printed lines (due to less loaded child processes) You are getting the same output because you are not encountering any 'edge' cases I'd recommend watching the previous lecture because this was discussed :)


SVG not supported

Login to reply

👍?
helpful
12:00pm Thu 29th Aug, ANONYMOUS

"David Charkey" <22*7*4*8@s*u*e*t*u*a*e*u*a*> wrote:
> I think one of the cases was that the RAM is full and no more programs can be loaded into > memory, which would result in less than 4 printed lines (due to less loaded child processes) > > You are getting the same output because you are not encountering any 'edge' cases > > I'd recommend watching the previous lecture because this was discussed :)
I thought about that as well, but since the question states the "code executes successfully", I assumed no such cases should be considered.


SVG not supported

Login to reply

👍?
helpful
2:01pm Thu 29th Aug, ANONYMOUS

Could someone please respond to this to clarify, because I also assumed that since the code had executed correctly, there were 4. I'm now more confused then before on what to answer.


SVG not supported

Login to reply

👍?
helpful
2:12pm Thu 29th Aug, Michael S.

ANONYMOUS wrote:
> Could someone please respond to this to clarify, because I also assumed that since the code had > executed correctly, there were 4. I'm now more confused then before on what to answer.
I would guess that Chris means the code did not error out. fork() returns a negative number if no children are created, it does not terminate or cause the program to terminate.


SVG not supported

Login to reply

👍?
helpful
2:45pm Thu 29th Aug, ANONYMOUS

So we are to assume that the code did not execute successfully and it, therefore, doesn't print out hello world 4 times? Bit confusing of a question since you can choose D for most answers then if it was an option could you not?


SVG not supported

Login to reply

👍?
helpful
2:52pm Thu 29th Aug, ANONYMOUS

ANONYMOUS wrote:
> So we are to assume that the code did not execute successfully and it, therefore, doesn't print out > hello world 4 times? Bit confusing of a question since you can choose D for most answers then if it was > an option could you not
I reviewed lectures last night and found that in lecture6 or 7 ,it says that fork is for mac OS& linux, createprocess is for windows. But fork() function worked well when I executed the program in my windows computer...


SVG not supported

Login to reply

👍?
helpful
8:50pm Thu 29th Aug, ANONYMOUS

so which answer is definitely going to give me the mark if a question like this pops up...


SVG not supported

Login to reply

👍?
helpful
2:25pm Sat 31st Aug, ANONYMOUS

E.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy