You are on page 1of 23

Course code

MCS-041

Course Title
Assignment Number
Maximum Marks
Weightage
Last Dates for Submission

:
:
:
:
:

Operating Systems
MCA(4)/041/Assign/2014-15
100
25%
15th October, 2014 (For July 2014 Session)
15th April, 2015 (For January 2015 Session)

Question 1: On a disk with 1000 cylinders, numbers 0 to 999, compute the number of tracks the disk arm
must move to satisfy all the requests in the disk queue. Assume the last request serviced was
at track 345 and head is moving to track 0. The queue in FIFO order contains requests for the
following tracks: 123,874,692, 475,105, 376. Perform the computation for the following disk
scheduling algorithms:
(a) FIFO (b) SSTF (c) SCAN (d) LOOK

Answer :
(a)
The simplest form of disk scheduling is, of course, the first-In, First Out (FIFO) algorithm. This algorithm is
intrinsically fair, but it generally does not provide the fastest service. Consider, for example, a disk queue
with requests for I/O to blocks on cylinders 123,874,692, 475,105, 376.
Hence, the queue:123,874,692, 475,105, 376.
Head starts at 345

Therefore, the tracks traveled to will be 345, 123, 874, 692, 475, 105 and 376 making the total distance 222
+ 751+182+217+370+271 = 2013.
(b)
It seems reasonable to service all the requests close to the current head position before moving the head far
away to service other requests. This assumption is the basis for the shortest-seek-time-first (SSTF)
algorithm. The SSTF algorithm selects the request with the minimum seek time from the current head
position. Since seek time increases with the number of1 cylinders traversed by the head, SSTF chooses the
pending request closest to the current head position.
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Hence, the queue:123,874,692, 475,105, 376.


Head starts at 345

Therefore, the tracks traveled to will be 345, 376, 475, 692, 874, 123 and 105 making the total distance
529 +769 = 1298.
(c)
In the SCAN algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing
requests as it reaches each cylinder, until it gets to the other end of the disk. At the other end, the direction of
head movement is reversed, and servicing continues. The head continuously scans back and forth across the
disk. The SCAN algorithm is sometimes called the elevator algorithm, since the disk arm behaves just like
an elevator in a building, first servicing all the requests going up and then reversing to service requests the
other way.

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Hence the queue:123,874,692, 475,105, 376.


Head starts at 345

Therefore, the tracks traveled to will be 345, 123, 105, 0, 376, 475, 692 and 874 making the total distance
345 + 874 = 1219.
(d)
As we described them, both SCAN and C-SCAK move the disk arm across the full width of the disk. In
practice, neither algorithm is often implemented this way.
Hence the queue:123,874,692, 475,105, 376.
Head starts at 345

Therefore, the tracks traveled to will be 345, 123, 105,3376, 475, 692 and 874 making the total distance 240
+ 769 = 1009.
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Question 2:

Consider the following set of processes, with the length of the CPU burst
time given in milliseconds.
Process

Burst time

Priority

P1
P2
P3
P4
P5

8
3
4
7
6

3
1
4
2
5

P4

The processes are assumed to have arrived in the order P1, P2, P3, P4 and P5 all at time.
a) Draw four Gantt charts illustrating the execution of these processes using
FCFS, SJF a non-preemptive priority (a smaller priority number implies a
higher priority) and Round Robin (quantum=2)scheduling.
b) What is the turnaround time of each process for each of the scheduling
algorithm in (a)?
c) What is the waiting time of each process for each of the scheduling algorithm
in (a)?
d) Which of the schedules in (a) results in minimal average waiting time
(overall processes)?

Answer :
(a) + (b) + (c)

Turnaround time. From the point of view of a particular process, the important criterion is
how long it takes to execute that process. The interval from the time of submission of a process to
the time of completion is the
turnaround time. Turnaround time is the sum of the periods spent waiting to get into memory,
waiting in the ready queue, executing on the CPU, and doing I/O.

Waiting time. The CPU scheduling algorithm does not affect the amount of time during
which a process executes or does I/O; it affects only the amount of time that a process spends
waiting in the ready queue. Waiting time is the sum of the periods spent waiting in the ready
queue.

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

FCFS :
Gantt chart
P1

P2

P3

P4

11

P5

15

22

Waiting Time

Turn Around Time

P1 = 8 8 = 0

P1 = O + 8 = 8

P2 = 11 3 = 8

P2 = 8 + 3 = 11

P3 = 15 4 = 11

P3 = 4 + 11 = 15

P4 = 22 7 = 15

P4 = 15 + 7 = 22

P5 = 25 3 = 22

P5 = 6 + 22 = 28

28

Avg. waiting time : (0 + 8 + 11 + 15 + 22) / 5 = 11.2

SJF :
Gantt chart
P2

P3

P5

P4

P1

13

20

Waiting Time

Turn Around Time

P1 = 28 8 = 20

P1 = 2O + 8 = 28

P2 = 3 3 = 0

P2 = 0 + 3 = 3

P3 = 7 4 = 3

P3 = 3 + 14 = 7

P4 = 20 7 = 13

P4 = 13 + 7 = 20

P5 = 13 6 = 7

P5 = 7 + 6 = 13

28

Avg waiting time : (20 + 0 + 3 + 13 + 7) / 5 = 8.6

Priority Scheduling :
Gantt chart

P2

P4

P1
10

P3
18

P5
22

28

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Waiting Time

Turn Around Time

P1 = 18 8 = 10

P1 = 10 + 8 = 18

P2 = 3 3 = 0

P2 = 0 + 3 = 3

P3 = 22 4 = 18

P3 = 18 + 4 = 22

P4 = 10 7 = 3

P4 = 3 + 7 = 10

P5 = 28 6 = 22

P5 = 22 + 6 = 28

Avg. waiting time : (10 + 0 + 18 + 3 + 22) / 5 = 10.6

Round Robin scheduling. (quantum=2)


Gantt chart
P1
P2
P3
0
2
4

P4
P5
P1
P2
6
8
10
12

P3
P4
13
15

P5
P1
17 19

P4
P5
P1
P4
21
23 25 27 28

Waiting Time

Turn Around Time

P1 = 27 8 = 19

P1 = 27 0 = 27

P2 = 13 3 = 10

P2 =13 2 = 11

P3 = 15 4 = 11

P3 = 15 4 = 11

P4 = 28 7 = 21

P4 = 28 6 = 22

P5 = 25 6 = 19

P5 = 25 8 = 17

Avg. waiting time : (19 + 10 + 11 + 21 + 19) / 5 = 16

d) From the above discursion it is seen that SJF has the minimum avg. waiting time.
Question 3:

Consider the following page-reference string:


1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. How many page faults would
occur for the following replacement algorithms, assuming three frames?
Remember all frames are initially empty.
a. FIFO replacement b. LRU replacement c. Optimal
Mention the merits and demerits of each of the above algorithms.

Answer :

a)
For FIFO replacement algorithm:
The simplest page-replacement algorithm is a first-in, first-out (FIFO) algorithm. A FIFO replacement
algorithm associates with each page the time when that page was brought into memory. When a page must
be replaced, the oldest page is chosen. Notice that it is not strictly necessary to record the time when a page
is brought in. We can. create a FIFO queue to hold all pages in memory. We replace the page at the head of
the queue. When a page is brought into memory, we insert
6 it at the tail of the queue.

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

:: for 3 page frames


Request
Page
frames

Page
fault

1
1*

2
1
2*

3
1
2

4
4*
2

2
4
2*

1
4
1*

5
4
1

6
6*
1

2
6
2*

1
6
2

2
6
2*

3
3*
2

7
3
7*

6
3
7

3
3*
7

2
2*
7

1
2
1*

2
2*
1

3
2
1

6
6*
1

3*

5*

1*

6*

3*

No

No

No

No

3
1
2

4
1
2

2
1
2*

1
1*
2

5
1
2

6
6*
2

2
6
2*

1
6
1*

2
6
1

3
6
1

7
6
1

6
6*
1

3
6
1

2
6
1

1
6
1*

2
6
1

3
6
1

6
6*
1

3*

2*

2*

2*

4*

3*

3*

3*

5*

7*

no

no

no

no

No

:: for 5 page frames


Request
Page
frames

Page
fault

1
1*

2
1
2*

No

No

No

no

no

3
1
2

4
1
2

2
1
2*

1
1*
2

5
1
2

6
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

7
1
2

6
1
2

3
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

6
1
2

3*

3*

3*

3*

4*

5*

6*

6*

6*

7*

no

No

no

no

no

No

no

:: for 7 page frames


Request
Page
frames

Page
fault

1
1*

Page Frame
3
5
7

2
1
2*

No

No

no

No

no

No

Page fault
16
10
7

Advantages of FIFO
>>Obvious improvement over FIFO
>>Allows commonly used pages to stay in queue
Disadvantages of FIFO
>>Still suffers from Belady's anomaly

b) For LRU replacement algorithm:


If the optimal algorithm is not feasible, perhaps an approximation of the optima] algorithm is possible. The
key distinction between the FIFO and OPT algorithms (other than looking backward versus forward in time)
is that the FIFO algorithm uses the time when a page was brought into memory, whereas the OPT algorithm
uses the time when a page is to be used. If we use the recent past as an approximation of the near future,
then we can replace the page that has not been used
7 for the longest period of time (Figure 9.15). This
approach is the least-recently-used (LRU) algorithm.
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

:: for 3 page frames

Request 1 2
Page
1* 1
frame
2*
(3)

3
1
2
3*

4
4*
2
3

2
4
2*
3

5
5*
2
1

6
5
6*
1

2
5
6
2*

1
1*
6
2

2
1
6
2*

3
1
3*
2

7
3
7*
2

no

1
4
2
1*

no

Request
Page
frame
(5)

1 2 3
1* 1 1
2* 2
3*

4
1
2
3
4*

2
1
2*
3
4

1
1*
2
3
4

1
1*
2
6
4
5

2
1
2*
6
4
5

no

no

6
1
2
6*
4
5

2
1
2*
6
4
5

5
1
2
3
4
5*

no

no

no

3
1
2
6
3*
5

Page
fault

Page
frame
(7)

1 2 3
1* 1 1
2* 2
3*

4
1
2
3
4*

2
1
2*
3
4

1
1*
2
3
4

5
1
2
3
4
5*

6
1
2
3
4
5
6*

2
1
2*
3
4
5
6

1
1*
2
3
4
5
6

2
1
2*
3
4
5
6

Page fault

no no

Page
fault

6
3
7
6*

3
3*
7
6

7
1
2
6
3
7*

6
1
2
6*
3
7

3
1
2
6
3*
7

2
1
2*
6
3
7

1
1*
2
6
3
7

2
1
2*
6
3
7

3
1
2
6
3*
7

6
1
2
6*
3
7

no

no

no

no

no

no

No

7
1
2
3
4
5
6
7*
no no no no

6
1
2
3
4
5
6*
7
no

3
1
2
3*
4
5
6
7
no

2
1
2*
3
4
5
6
7
No

1
1*
2
3
4
5
6
7
no

2
1
2*
3
4
5
6
7
no

3
1
2
3*
4
5
6
7
No

6
1
2
3
4
5
6*
7
No

no

2
3
2*
6

1
3
2
1*

2
3
2*
1

3
3*
2
1

no

no

6
3
2
6*

:: for 5 page frames

:: for 7 page frames


Request

Page Frame
3
5
7

3
1
2
3*
4
5
6

Page fault
15
8
7

Advantages
Advantages of LRU Page Replacement Algorithm:
1.
2.

It is amenable to full statistical analysis.


Never suffers from Beladys anomaly.

Disadvantages
To identify the page to replace, you need to find the minimum time stamp value in all the
registers.
8

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

c)
For Optimal Page replacement algorithm:
One result of the discovery of Belady's anomaly was the search for an optimal page-replacement
algorithm. An optimal page-replacement algorithm has the lowest page-fault rate of all algorithms and will
never suffer from Belady's anomaly. Such an algorithm does exist and has been called OPT or MIK.
:: for 3 page frames
Request
Page
frame

Page
fault

1
1*

2
1
2*

3
1
2

4
1
2

2
1
2*

1
1*
2

5
1
2

6
1
2

2
1
2*

1
1*
2

2
1
2*

3
3*
2

7
3
7*

6
3
7

3
3*
7

2
3
2*

1
3
2

2
3
2*

3
3*
2

6
3
2

3*

4*

5*

6*

6*

1*

6*

No

No

No

no

no

No

No

No

no

3
1
2

4
1
2

2
1
2*

1
1*
2

5
1
2

6
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

7
1
2

6
1
2

3
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

6
1
2

3*

3*

3*

4*

6*

6*

5*

7*

:: for 5 page frames


Request
Page
frame

Page
fault

1
1*

2
1
2*

No

No

No

no

no

no

no

no

no

no

no

no

No

3
1
2

4
1
2

2
1
2*

1
1*
2

5
1
2

6
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

7
1
2

6
1
2

3
1
2

2
1
2*

1
1*
2

2
1
2*

3
1
2

6
1
2

3*

3*

3*

3*

4*

5*

6*

6*

6*

7*

no

No

no

no

No

no

no

no

no

no

No

:: for 7 page frames


Request
Page
frame

Page
fault

1
1*

2
1
2*

Page Frame
3
5
7

No

No

Page fault
11
7
7

Advantage
Advantage of the optimal page replacement algorithm is that it has the lowest rate of occurrence of page
faults. Hypothetically, it improves the system performance by reducing overhead for number of page
faults and swapping pages in and out, when a page fault occurs.
9

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Disadvantage
Disadvantage of the optimal page replacement policy is that it is very difficult to implement. The
situation is very similar to that of implementing the SJF algorithm in process management. It becomes
very difficult for an operating system to calculate after what interval a page is to be referred to.

Question 4:

Android has continued upgrading since it was first launched a few years ago and
utilizes a special name each time it releases a new version of the platform. The latest
version is Android 4.4.2. Mention its features and also compare this with the earlier
versions namely Gingerbread, Ice Cream Sandwich and Jelly Bean.
(15 Marks)

Answer :
Android is a mobile operating system (OS) based on the Linux kernel and currently developed
by Google. With a user interface based on direct manipulation, Android is designed primarily
for touchscreenmobile devices such as smartphones and tablet computers, with specialized user
interfaces for televisions (Android TV), cars (Android Auto), and wrist watches (Android Wear). The
OS uses touch inputs that loosely correspond to real-world actions, like swiping, tapping, pinching, and
reverse pinching to manipulate on-screen objects, and a virtual keyboard. Despite being primarily
designed for touchscreen input, it also has been used in game consoles, digital cameras, and other
electronics.
Android is the most popular mobile OS. As of 2013, Android devices sell more than Windows, iOS,
and Mac OS devices combined, with sales in 2012, 2013 and 2014 close to the installed base of all
PCs. As of July 2013 the Google Play store has had over 1 million Android apps published, and over 50
billion apps downloaded. A developer survey conducted in AprilMay 2013 found that 71% of mobile
developers develop for Android. At Google I/O 2014, the company revealed that there were over 1
billion active monthly Android users (that have been active for 30 days), up from 538 million in June
2013.

Features of Latest Android 4.4.2 version:


From 2010 to 2013, Hugo Barra served as product spokesperson for the Android team,
representing Android at both press conferences and Google I/O, Googles annual developerfocused conference. Barras product involvement included the entire Android ecosystem of
software and hardware, including Honeycomb, Ice Cream Sandwich, Jelly Bean and KitKat (ie.
Android 4.4.2 version) operating system launches, the Nexus 4 andNexus 5 smartphones,
the Nexus 7 and Nexus 10 tablets, and other related products such as Google Now[ and Google
Voice Search, Googles speech recognition product comparable to ApplesSiri In 2013 Barra left
the Android team for Chinese smartphone maker Xiaomi
What we have here is an incremental improvement, with subtle visual upgrades that enrich the
experience without being glaringly obvious. The removal of the black background on the
notification bar is one such example.
And everything is white. Well, not everything just all the status icons, things like Wi-Fi, Battery,
10
and Data. The switch from blue to white is most evident at the top of the display, where the time
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

and battery icons live. Its not a big change in the grand scheme of things, but it is change
nonetheless. And the thinking behind the switch is explained below:
Aesthetic concerns definitely factored into this (as has been mentioned elsewhere, a more neutral
SystemUI allows apps to manage their own color palettes a bit better), but also keep in mind that
with the new translucent bars feature, the color became a usability problem.
The latest addition to Googles Android KitKat platform, update 4.4.2, is now rolling out to select
handsets. Here's the changelog:

A tweaked Dialer app with a colored Action bar.

Peoples app now placeholder images are now similar to that one used by Gmail.

Fix for mm-qcamera-daemon bug.

The hissing sound while recording videos on the Nexus 5 is fixed. However, there is now a
strange echo in the recorded audio.

Fix for LTE connection dropping bug.

Wi-Fi improvements.

Microphone and earphone related changes.

Lot of other under-the-hood camera,Bluetooth and other system related bug-fixes.

Compare Android 4.4.2 version with Gingerbread, Ice Cream Sandwich and Jelly Bean
Version
name

Key user features added

Jelly Bean

Android 4.2

Key developer features Releas Androi


added
e date
d
market
share

Lockscreen widgets

vsync timing

360 degree images

Triple buffering

with Photo Sphere

Gesture Typing, for


faster typing

Wireless display

<,dfn
class="suggest
action scact-52"
title="Suggestion">
17

latency
CPU input boost

Native RTL
support - mirrors the

Daydream to

display from manifest prop

display information when idle


or docked

19.1
% (4.2
4.2.2)

reduced touch

with Miracast

2012
Nov
13

API Level

External display
support - Display Manager

Multi-user for

tablets

Nested
fragments

Renderscript
Compute - run tasks on the

11
GPU (supported devices)

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

Renderscript

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Key developer features Releas Androi


added
e date
d
market
share

API Level

ScriptGroups, built-in
intrinsics like blur,

FilterScript is a
subset of Renderscript
made for high
performance image
processing

Jelly Bean

Android
4.1.2

Enable Home

2012
Oct 9

29 %
(4.1 4.1.2)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
16

2012
Jul
23

29 %
(4.1 4.1.2)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
16

2012
Jul 9

29 %
(4.1 4.1.2)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
16

2012
Mar
28

12.3
%
(4.0.3
4.0.4)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
15

screen rotation

Fix bugs and


enhance performances

Jelly Bean

Android
4.1.1

Fix a bug on screen


orientation

Jelly Bean

Android 4.1

Google Now

app stack

( http://youtu.be/pPqliPzHYyc

navigation to define a

parent activity in manifest

Voice Search

Speed

for deep navigation

enhancements

nd class to make sounds

Camera app

like when a camera takes a

improvements

MediaActionSou

photo

Accessibility:

NFC supports

gesture mode, enable braille

large payloads over

external keyboards...

bluetooth

WIFI/WIFIDirect service discovery

Large, detailed,
multi-action notifications

Input manager
allows you to query input
devices

Ice Cream
Sandwich

Android
4.0.4

stability

12

improvements

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Key developer features Releas Androi


added
e date
d
market
share

API Level

better camera
performance

smoother screen
rotation

Ice Cream
Sandwich

Android
4.0.3

Social stream API


in Contacts provider to show

2011
Dec
16

12.3
%
(4.0.3
4.0.4)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
15

2011
Nov
28

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
14

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
14

updates associated to your


contacts

Video stabilization
and QVGA video resolution
API access

Accessibility API
refinements for screen readers

Calendar provider
updates

Android
4.0.2

Ice Cream
Sandwich

Android 4.0

Ice Cream
Sandwich

Minor fixes

New lock screen

actions

streaming multimedia
Improved text input

and spell-checking

Control over

(Khronos OpenMAX AL

Grid Layout

Spell checking

network data

Low-level

service

Email app supports


EAS v14

Address Space
Layout Randomization

WI-FI direct

VPN client API

BlueTooth Health

Remote Device

Device Profile

camera enable/disable

ZSL exposure,
continuous focus, and
image zoom

Flags to help
control system ui elements

13

like system bar from apps

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Ice Cream
Sandwich

Android
4.0.1

Key developer features Releas Androi


added
e date
d
market
share

Facial recognition
(Face Unlock)

API Level

2011
Oct
19

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
14

UI use Hardware
acceleration

Better voice
recognition (dictating/Voice
typing)

Web browser,
allows up to 16 tabs

Updated launcher
(customizable)

Android Beam app


to exchange data through
NFC

Android
3.2.6

Honeycom
b

Minor fixes

2012
Feb
15

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
13

Android
3.2.4

Honeycom
b

Added "Pay as you go" for


tablets

2011
Dec
15

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
13

Android
3.2.2

Honeycom
b

Minor fixes

2011
Sep
30

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
13

Android
3.2.1

Honeycom

2011
Sep
20

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
13

2011
Jul
15

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">

Android Market
updates including easier
automatic updates

Google Books
updates

Wi-Fi
improvements

Chinese
handwriting prediction
improved

Honeycom

Android 3.2

Optimizations for a
wider range of tablets

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

14

Extended API

for managing screens

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Key developer features Releas Androi


added
e date
d
market
share

Compatibility

API Level

13

support

display mode (zoom for fixed

sized apps)

Media sync from

New
resource qualifiers for

SD card

screens support

New
manifest attributes for
screen-size compatibility

Screen
compatibility mode which
allows for phone apps to
appear as if they were still
on a phone

Honeycom

Android 3.1

UI improvements

Open Accessory

2011
May
10

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
12

2011
Feb
22

0%

<,dfn
class="suggest
action scact-52"
title="Suggestion">
11

API

USB host API

Mice, joysticks,
gamepads... support

Resizable Home
screen widgets

Android 3.0

MTP notifications

RTP API for audio

Honeycom

Multi core support

Better tablet support

Updated 3D UI

customiza

recent
applications viewing

Email:

Pluggable DRM
framework

Google Talk video

Tripura.

Renderscript 3D
graphics engine

Media/Picture
transport protocol

Das,

keyboard layout

Belonia,

Hardwareaccelerated 2D graphics

redone

now supports it as well)

ble homescreens

Abir

Fragments first
introduced(support library

by:

bar

Created

contextual action

15

device

administration

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Key developer features Releas Androi


added
e date
d
market
share

chat

High

Google eBooks

performance Animation

"Private browsing"

Framework

System-wide

Clipboard

API Level

RTP streaming
API

HTTP Live
streaming

Forced rendering
of layers

High
performance WIFI lock

Vew network
traffic stats

ADTS AAC and


FLAC audio

Gingerbrea

Android 2.3.
4

Voice or video chat


using Google Talk

Gingerbrea

Android
2.3.7

LRU cache

Open Accessory
API

2011
May
10

14.9
%
(2.3.3
2.3.7)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
10

14.9
%
(2.3.3
2.3.7)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
10

14.9
%
(2.3.3
2.3.7)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
10

2011
Jul
25

14.9
%
(2.3.3
2.3.7)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
10

2011
Feb 9

14.9
%
(2.3.3
2.3.7)

<,dfn
class="suggest
action scact-52"
title="Suggestion">
10

Google Wallet
support for the Nexus S 4G

Gingerbrea

Android
2.3.6

Voice search issue


fixed

Gingerbrea

Android
2.3.5

Improved network
performance for the Nexus S
4G

Fixed Bluetooth
issues on the Samsung Galaxy
S

Gmail app.
improvements

Gingerbrea
d

Android
2.3.3

NFC API
improvements (peer to
peer communication...)
16

Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

added unsecure

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Version
name

Key user features added

Key developer features Releas Androi


added
e date
d
market
share

API Level

bluetooth sockets

Question 5:
code briefly.

Write a program in C to implement Bankers Algorithm to avoid Deadlock. Also explain the
(10 Marks)

Answer :
C program of bankers algorithm to avoid deadlock : Bankers algorithm is a resource
allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for
safety by simulating the allocation of predetermined maximum possible amounts of all
resources, and then makes a s-state check to test for possible deadlock conditions for all
other pending activities, before deciding whether allocation should be allowed to continue.
How Bankers Algorithm works ?
The Bankers algorithm is run by the operating system whenever a process requests
resources. The algorithm avoids deadlock by denying or postponing the request if it
determines that accepting the request could put the system in an unsafe state (one where
deadlock could occur). When a new process enters a system, it must declare the maximum
number of instances of each resource type that may not exceed the total number of resources
in the system. Also, when a process gets all its requested resources it must return them in a
finite amount of time.
Let us see how to implement Bankers algorithm in C which takes number of processes and
resources as input shows state as output.

C program of Bankers Algorithm to avoid deadlock :


#include<stdio.h>
#include<conio.h>
int main()
{
int clm[7][5],req[7][5],alloc[7][5],rsrc[5],avail[5],comp[7];
int first,p,r,i,j,prc,count,t;
count=0;
Created

by:

Abir

Das,

Belonia,

17

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

for(i=1;i<=7;i++)
comp[i]=0;
printf("----------------------------------------------------\n");
printf("-------------Made by C codechamp-------------------\n");
printf("----------------------------------------------------\n\n");
printf("\t BANKERS ALGORITHM IN C \n\n");
printf("Enter the no of processes : ");
scanf("%d",&p);
printf("\n\nEnter the no of resources : ");
scanf("%d",&r);
printf("\n\nEnter the claim for each process : ");
for(i=1;i<=p;i++)
{
printf("\nFor process %d : ",i);
for(j=1;j<=r;j++)
{
scanf("%d",&clm[i][j]);
}
}
printf("\n\nEnter the allocation for each process : ");
for(i=1;i<=p;i++)
{
printf("\nFor process %d : ",i);
for(j=1;j<=r;j++)
{
scanf("%d",&alloc[i][j]);
}
}
printf("\n\nEnter total no of each resource : ");
for(j=1;j<=r;j++)
scanf("%d",&rsrc[j]);
18
for(j=1;j<=r;j++)
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

{
int total=0;
avail[j]=0;
for(i=1;i<=p;i++)
{total+=alloc[i][j];}
avail[j]=rsrc[j]-total;
}
do
{
for(i=1;i<=p;i++)
{
for(j=1;j<=r;j++)
{
req[i][j]=clm[i][j]-alloc[i][j];
}
}
printf("\n\nAvailable resources are : ");
for(j=1;j<=r;j++)
{ printf(" ",avail[j]); }
printf("\nClaim matrix:\tAllocation matrix:\n");
for(i=1;i<=p;i++)
{
for(j=1;j<=r;j++)
{
printf("%d\t",clm[i][j]);
}
printf("\t\t\t");
for(j=1;j<=r;j++)
{
printf("%d\t",alloc[i][j]);
}
19
printf("\n");
}
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

prc=0;
for(i=1;i<=p;i++)
{
if(comp[i]==0)//if not completed
{
prc=i;
for(j=1;j<=r;j++)
{
if(avail[j]=0)
{
prc=0;
break;
}
}
}
if(prc!=0)
break;
}
if(prc!=0)
{
printf("\nProcess ",prc,"runs to completion!");
count++;
for(j=1;j<=r;j++)
{
avail[j]+=alloc[prc][j];
alloc[prc][j]=0;
clm[prc][j]=0;
comp[prc]=1
;
}
}
}
20
while(count!=p&&prc!=0);
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

if(count==p)
printf("\nThe system is in a safe state!!");
Else
printf("\nThe system is in an unsafe state!!");
getch();
}

Explanation : Several data structures must be maintained to implement the banker's algorithm.
These data structures encode the state of the resource-allocation system. Let n be the number of
processes in the system and m be the number of resource types. We need the following data
structures: Available. A vector of length m indicates the number of available resources of each
type. If Availab!c[f] equals k, there are k instances of resource type Ri available. Max. An n x m
matrix defines the maximum demand of each process. If M(7.t[;][/] equals k, then process P\ may
request at most k instances of resource type /?/.
Allocation. An n x in matrix defines the number of resources of each type currently allocated to each
process. If Allocation[i][j] equals k, then process Pi is currently allocated k instances of resource type /?,.
Need. An n x m matrix indicates the remaining resource need of each process. If Need[i][j] equals k, then
process P,- may need k more instances of resource type R- to complete its task. Note that Need[/][/] equals
Max[i][j] - Allocntion[i][j].
These data structures vary over time in both size and value. To simplify the presentation of the banker's
algorithm, we next establish some notation. Let X and Y be vectors of length n. We say that X < Y if and
only if X[i] < Y[/] for all / = 1, 2, ..., n. For example, if x"= (1,7,3,2) and Y = (0,3,2,1), then Y < X. Y < X if
Y < X and Y + X. We can treat each row in the matrices Allocation and Need as vectors and refer to them
as Allocation; and Need,. The vector Allocation, specifies the resources currently allocated to process P,;
the vector Needi specifies the additional resources that process P, may still request to complete its task.

Question 6:
a) What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what
can the system do to eliminate this problem?
(15 Marks)
b) Explain in detail how semaphores and monitors are used to solve the Dining-Philosopher problem.

Answer :
a)
Thrashing :
If the number of frames allocated to a low-priority process falls below the minimum number required by the
computer architecture, we must suspend, that process's execution. We should then page out its remaining
pages, freeing
all its allocated frames. This provision introduces a swap-in, swap-out level of intermediate CPU scheduling.
In fact, look at any process that does not have ''enough" frames. If the process does not have the number of
frames it needs to support pages in active use, it will quickly page-fault. At this point, it must replace some
page. However, since all its pages are in active use, it must replace a page that will be needed again right
away. Consequently, it quickly faults again, and again, and again, replacing pages that it must bring back in
21
immediately. This high paging activity is called thrashing. A process is thrashing if it is spending more time
paging than executing.
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

Thrashing is caused by under allocation of the minimum number of pages required by


a process, forcing it to continuously page fault.
The system can detect thrashing by evaluating the level of CPU utilization as
compared to the level of multiprogramming.
It can be eliminated by reducing the level of multiprogramming.
b)

Dining-Philosophers Solution Using Monitors


Monitor concepts illustrate can be illustrated by presenting a deadlock-free solution to the diningphilosophers problem. This solution imposes the restriction that a philosopher may pick up her chopsticks
only if both of them are available. To code this solution, we need to distinguish among three states in which
we may
find a philosopher. For this purpose, we introduce the following data structure:
enum {thinking, hungry, eating} state [5] ; Philosopher i can set the variable state [i] = eating only if her two
neighbors are not eating: (state [(i+4) / 5] != eating) and (state [(i+1) % 5] != eating).
We also need to declare condition self [5]; where philosopher ;' can delay herself when she is hungry but is
unable to
obtain the chopsticks she needs. We are now in a position to describe our solution to the diiiing-philosophers
problem. The distribution of the chopsticks is controlled by the monitor dp. Each philosopher, before
starting to eat, must invoke the operation pi ckup (). This may result in the suspension of the philosopher
process. After the successful completion of the operation, the philosopher may eat. Following this, the
philosopher invokes the putdownO operation. Thus, philosopher i must invoke the operations pi ckup () and
putdownO in the following sequence:

dp.pickup(i);
eat
dp.putdown(i);
monitor dp
Created

by:

Abir

22

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

enum {THINKING, HUNGRY, EATING}state [5]


condition self [5] ;
void pickup(int i) {
state [i] = HUNGRY;
test (i) ;
if (state [i] != EATING)
self [i] .wait() ;
void putdown(int i) {
state til = THINKING;
test((i + 4) % 5} ;
test( (i + 1) % 5) ;
void test(int i) {
if ((state [(i + 4) % 5] != EATING) &&
(state [i] == HUNGRY) &&
(state [(i + 1) % 5] != EATING)) {
state [i] = EATING;
self [i] .signal() ;
initialization-code () {
for (int i = 0; i < 5; i++)
state [i] = THINKING;
It is easy to show that this solution ensures that no two neighbors are eating simultaneously and that no
deadlocks will occur. We note, however, that it is possible for a philosopher to starve to death.

Implementing a Monitor Using Semaphores


We now consider a possible implementation of the monitor mechanism using semaphores. For each monitor,
a semaphore mut ex (initialized to 1) is provided. A process must execute wait (mutex) before entering the
monitor and must execute signal (mutex) after leaving the monitor. Since a signaling process must wait until
the resumed process either leaves or waits, an additional semaphore, next, is introduced, initialized to 0, on
which the signaling processes may suspend themselves. An integer variable next-count is also provided to
count the number of processes suspended on next. Thus, each external procedure F is replaced by
uait(mutex);
body of F
if (next_count > 0)
signal(next);
else
signal(mutex);
Mutual exclusion within a monitor is ensured. We can now describe how condition variables are
implemented. For each condition x, we introduce a semaphore x_sem and an integer variable x_count,
both initialized to 0. The operation x. wait () can now be implemented as
x_count++;
if (next_count > 0)
signal(next);
else
signal(mutex);
wait(x_sem);
x_count;
The operation x. signal () can be implemented as
if (x_count > 0) {
next_count++;
signal(x_sem);
23
wait(next) ;
next_count--;
Created

by:

Abir

Das,

Belonia,

Tripura.

Email:

abiranna@gmail.com

abiralive@live.com

FaceBook

https://www.facebook.com/abiranna For any query contact me Plz like & send frnd reqst to me.

id

You might also like