Welcome! Log In Create A New Profile

Advanced

Assignment 1

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Anonymous User
Assignment 1
February 21, 2011 08:26AM
Does anyone know how to approach question 3 of Assignment 1? I've battled through the rest of the assignment, but don't have a clue what they refer to in this question. There is also no indication about this in the Multithreading chapter (which I think it is about).

Also, how can I make sense of question 5? I think I've got 5.2 figured out, but I'm not sure what the effect of 5.1 and 5.3 is. Anyone, help please!

Carina
avatar Re: Assignment 1
February 21, 2011 02:01PM
I forget exactly how I got to my answer to Q3, but I suspect it was simply by looking at why one would use the various things mentioned. eg. What's the point of having global variables?

I seem to recall that the fact that one process has multiple threads was somehow significant.

Imagining how one thread could disrupt another was also helpful.

No there's no dedicated section in the textbook on this.

(I've done a rough draft for Ass 2 already, so I first offered some suggestions on that. Then the "Q5 query" threw me... If you've not looked at these yet, take heart, I think it was a bit easier overall)

OK so my method in Q5 was simply to step it out. Put some values in there, and follow the algorithm, and see what happens. I did this, setting out my "observations", and then characterised them (as eg. FCFS, LRU, etc)

Hope that's at least not unhelpful. I actually need to review my answers and get this one posted, so if that process jogs my memory a bit better I'll come back here.
avatar Re: Assignment 1
February 21, 2011 02:04PM
Er... the one process, many threads thing means the process has some stuff that's common to all its threads. I still don't properly remember exactly why that seemed significant. Didn't include it specifically in any answer.

Why are threads economical? Because they don't have every resource a full blown process has, right?
Anonymous User
Re: Assignment 1
February 22, 2011 04:58PM
Thanks slow_eddy

I'll have another look, and give it a good go. I haven't even thought about Assignment 2 yet! (But thanks for the advice!)
avatar Re: Assignment 1
February 23, 2011 03:36PM
Hoped to have somehow had a more positively useful response for you by now (with all those good intentions of revising answers/ putting them under the critical spotlight), but I just don't seem to get back round here.

I dimly recall that the answer (which for me was never a case of "the lights going on"winking smiley was not near some diagram of the resources or anything like that, but inside the middle of a paragraph on the subject...

And now I begin to imagine I saw a bloomin' diagram!

If I ever get to improve my answer I'll come back here with the news.
Re: Assignment 1
February 25, 2011 12:44PM
Can you elaborate on what Q3 is? Maybe some of us that have completed this module could help? - just maybe.
The scheduling algorithms aren't too difficult, nor is figuring out how they perform. The best is usually to evaluate each algorithm given by running through:
  • Only 1 process
  • 2 Processes
  • 3 Processes - you should have identified a trend by now.
avatar Re: Assignment 1
February 25, 2011 06:16PM
Q3:

Which of the following components of a program state are shared across threads in a multithreaded process? Justify your claims.

a. Register values.
b. Heap memory.
c. Global variables.
d. A stack in memory.

There isn't a direct answer to this in the text book (nothing one can simply read off some page), so it takes a bit of figuring/ perhaps just common sense?

I've at least found the diagram I think I mentioned above. It's the one on page 154. I seem to recall that what I imagined the justifications to be came from this general vicinity, too. I suppose that's of no use if you've already sold your text book to the book pulpers, though.
Re: Assignment 1
February 26, 2011 02:14AM
Eddy - I haven't sold my textbooks yet (and don't intend to either), but I am unfortunately a good 11000kms away from my books.
I'm currently traveling in Australia.

I vaguely recall the diagram you are referring to - although IIRC (and my memory is a little dodgy - still fighting off jet lag and loss of sleep), the diagram may have been a schematic of the parent-child process - but I may be wrong.

The only immediate option that jumps out at me is C. - Global Variables.
A) Register Values - doesn't make sense
cool smiley Heap Memory - yeah right, can you imagine how long that might take to copy in the initialization of each thread, and how much memory each thread would then need on startup. This would be very expensive and would yield no advantage over the use of multiple processes as opposed to threads.
D) Stack Memory - hmmm, dodgy. I'm not sure on this one.
avatar Re: Assignment 1
February 26, 2011 03:53PM
You poor lucky bustard!

One way to cope with the jet lag is to go onto Lucky-Country-Time, without regard to the complaints of your biological clock, right away. So you go through the day, refusing to accept that it's night time, and that you therefore need to sleep. Then as you start becoming highly alert near bedtime at daybreak, pop a good quality sleeping tablet - something like Zolpidem, prescribed, not over the shelf. Kapow. Switch it all off, and force some sleep at the right time.

The alternative is to just wait about 2 weeks. It takes about that long to completely wear off.

As far as stacks go, every thread is going to need one. As the "main process" is just one of the threads, as soon as you start threading, this does not have some kind of "upper level stack" - which it would be hard to imagine doing anything.

Thanks for taking time out of your holiday to help out.

Australia is the place to be! 5 000 000 000 000 000 flies can't be wrong!

(So said an Aussie T-shirt from the time of the dinosaurs)

Trick with the flies is just let 'em be. They're living creatures, too. They're just taking a little rest and drink of your sweat streams. Soon they'll be gone, poor little mites, to fly around and around again. Hard work being a fly. If you give into the temptation to swot them, you'll spend your entire day doing nothing else. Let them tickle your arm, and eventually it feels quite nice. Of course when one tries to have a drink from the corner of your eye, or wanders over your lip, give it a shoo ..
Re: Assignment 1
February 27, 2011 11:38AM
No worries - unfortunately all work and no play.

I agree that each thread is given a stack - but I don't believe the stack is shared with other threads or the parent process.
Anonymous User
Re: Assignment 1
February 28, 2011 11:52AM
Hi guys - sorry I'm only back on board (excuse the pun, AndreB!) now. I've had to deal with some other issues (attending an off-site course being one of them) the last few days, so needless to say I've only looked at my assignment again yesterday!

I'll check the diagram on page 154, slow_eddy, thanks! I agree with AndreB, I think the stack isn't shared with any other threads, but not sure about the heap memory. (What is heap memory anyway? How's it different from any other memory?)

Thanks for your input, guys! Enjoy Aus, AndreB!
Re: Assignment 1
February 28, 2011 12:01PM
Thanks Carina - the heap is used for the create of new objects, specifically those instantiated with the new keyword -> i.e. used for dynamic memory allocation. IIRC, this is probably biggest section of memory given to process and each thread.
Each thread will be given their own heap memory, as each thread may need to dynamically allocate memory to objects that need to be created.

See the following links:
Difference between Heap & Stack memory
Dynamic Memory Allocation
Anonymous User
Re: Assignment 1
February 28, 2011 01:19PM
Thanks AndreB - this makes sense.
avatar Re: Assignment 1
March 01, 2011 11:08PM
Well I've just double-checked the answers I have for these, and I sincerely hope we're correct, here, since this is the gist of the answers I have.

I've also had another look at Q5, and I can't imagine another way of doing it. Even if you can see right away what kind of scheduling system is being used, it's convenient to just "run it", and then "notice" what kind of scheduling is being used. (And I've just looked back up this thread to see that this is what AndreB suggests, too, so at least anyone doing it that way will not be alone in being wrong, if wrong, it turns out to be).

Q4 is just the careful application of the "recipe", "running" a set of processes as SJF, priority, and round robin, and hopefully not fumbling a step. Looks like I'm at least making consistent mistakes here, so that one can go... which leaves Q1 and Q2. (Which look OK to me, but may turn out to produce something worth discussing when the scripts come back).
Sorry, only registered users may post in this forum.

Click here to login