COS3721 - Operating Systems And Architecture (COS3721)
All documents for this subject (31)
2
reviews
By: sbmbopape • 2 year ago
By: Rio12345 • 2 year ago
Seller
Follow
iStudy
Reviews received
Content preview
COS3721
EXAM PACK
, This paper consists of 5 pages.
Instructions:
1. Answer all the five (5) questions in your answer book.
2. All rough work must be done in your answer book.
3. Please answer the questions in order. If you want to do a question later, leave a blank space.
4. The string SGG (Silberschatz, Galvin & Gagne) refers to the prescribed book, namely,
Operating Systems Concepts, 9th edition for this module.
Good luck!
[TURN OVER]
, Page 2 of 10 COS3721
October/November 2018
Question 1 : 14 Marks
1.1 Describe some of the challenges of designing operating systems for mobile devices
compared with designing operating systems for traditional PCs. [4]
Answer:
The greatest challenges in designing mobile operating systems include:
Less storage capacity means the operating system must manage memory carefully.
The operating system must also manage power consumption carefully.
Less processing power plus fewer processors mean the operating system must carefully
apportion processors to applications.
1.2 Explain why Java programs running Android systems do not use the standard Java API and
virtual machine. [2]
Answer:
It is because the standard API and virtual machine are designed for desktop and server systems,
not mobile devices. Google developed a separate API and virtual machine for mobile devices.
1.3 A multithreaded web server wishes to keep track of the number of requests it services
(known as hits.) Consider the following two strategies to prevent a race condition on the variable
hits. The first strategy is to use a basic mutex lock when updating hits:
int hits;
mutex_lock hit_lock;
hit_lock.acquire();
hits++;
hit_lock.release();
A second strategy is to use an atomic integer:
Atomic_t hits;
Atomic_inc(&hits);
Explain which of these two strategies is more efficient. [4]
Answer:
The use of locks is overkill in this situation. Locking generally requires a system call and possibly
putting a process to sleep (and thus requiring a context switch) if the lock is unavailable.
(Awakening the process will similarly require another subsequent context switch.) On the other
hand, the atomic integer provides an atomic update of the hits variable and ensures no race
condition on hits. This can be accomplished with no kernel intervention and therefore the second
approach is more efficient.
[TURN OVER]
, Page 3 of 10 COS3721
October/November 2018
1.4 Which of the following scheduling algorithms could result in starvation? Explain.
[4]
(a) Shortest Job First
(b) Round-Robin
Answer:
(a) The SJF could result in starvation when shortest jobs keep on joining the ready queue which
already contains a process with highest burst time.
(b) RR could not result in starvation since each process ready for execution has equal chances to
be executed based on the time quantum.
Question 2: 24 Marks
2.1 Consider the following code segment:
Pid_t pid;
pid = fork( );
if ( pid = = 0 ) { / * child process * /
fork ( );
thread_create ( . . . );
}
Fork ( );
(a) How many unique processes are created? [2]
Answer:
There are six processes.
(b) How many unique threads are created? [2]
Answer:
There are two threads.
2.2 Consider a system consisting of four resources of the same type that are shared by three
processes, each of which needs at most two resources. Is this system deadlock free? Show the full
workings. [4]
Answer:
Suppose the system is deadlocked. This implies that each process is holding one resource and is waiting
for one more. Since there are three processes and four resources, one process must be able to obtain
two resources. This process requires no more resources and, therefore it will return its resources when
done.
2.3 Discuss how the following pairs of scheduling criteria conflict in certain settings. [6]
[TURN OVER]
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller iStudy. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $2.84. You're not tied to anything after your purchase.