• No results found

paper2 sol.doc

N/A
N/A
Protected

Academic year: 2020

Share "paper2 sol.doc"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Paper2 solution

Note: Attempt all Sections:

SECTION-A

1. Attempt all parts : (2 x 3=6) a. Explain the concept of Resident Monitor.

A resident monitor was a piece of system software in many early computers from the 1950s to 1970s. It can be considered a primitive precursor to the operating system. b. What is the Semaphore?

A semaphore ‘S’ is a synchronization tool which is an integer value that, apart from initialization, is accessed only through two standard atomic operations; wait and signal. Semaphores can be used to deal with the n-process critical section problem. It can be also used to solve various synchronization problems.

c. Explain the concept of Logical Address and Physical Address.

An address generated by the CPU is referred as logical address. An address seen by the memory unit that is the one loaded into the memory address register of the memory is commonly referred to as physical address.

SECTION-B

2. Attempt any THREE parts from the following: (5 x 3 = 15) a. Consider a Virtual Memory management scheme with Demand Paging. Maximum

Main Memory frames allocated to a process is 3. If referenced pages are 0, 1, 2, 3, 0, 1, 4, 0, 1, 2, 3, 4, 3, 4 Find number of page faults with FIFO & LRU Page Replacement strategy.

b. State and Describe the Producer Consumer Problem with its suitable solution.

CONCEPT:

Producers produce items to be stored in the buffer. Consumers

remove and consume items which have been stored. Mutual exclusion must

be enforced on the buffer itself. Moreover, producers can store only when

there is an empty slot, and consumers can remove only when there is a full

slot.

Three semaphores are used. The binary semaphore

mutex

controlls access to

the buffer itself. The counting semaphore

empty

keeps track of empty slots,

and the counting semaphore

full

keeps track of full slots.

In this example, the buffer is implemented as an array of size

MAX

treated as

a circular (ring) buffer. Variables

in

and

out

give the index of the next

posi-tion for putting in and taking out (if any). Variable

count

gives the number of

(2)

c. List out the Essential requirements of Critical Section Implementation. 1. Mutual Exclusion 2. Progress 3. Bounded Waiting

d. Compare and Contrast Internal and External Fragmentation. What are the different techniques to remove the fragmentation in case of Multiprogramming with fixed partition and variable partitions?

External fragmentation exists when enough total memory space exists to satisfy a request, but it is not contiguous; storage is fragmented into a large number of small holes. When the allocated memory may be slightly larger than the requested memory, the difference between these two numbers is internal fragmentation. Compaction is a solution to external fragmentation. The memory contents are shuffled to place all free memory together in one large block. It is possible only if relocation is dynamic, and is done at execution time.

e. In a segmentation based system, the main memory has the following holes in this order: 21K, 5K, 90K, 54K, 10K, 25K, 56K. There are three new requests for memory sizes 10K, 7K, 22K. The system does first come first serve service. Explain what holes will be taken for each of First Fit and Best Fit Memory allocation Schemes. Answer. For First fit, FCFS will be applied. So holes taken should be

10K  21 K, 7K  90K, 22K  54K.

For Best Fit, search on each hole is applied to select best hole, as 10K  10 K, 7K  21K, 22K  25K.

SECTION-C

(3)

a. State the Dining Philosopher problem. Write the solution to this Problem.

Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed be-tween each pair of adjacent philosophers.

Each philosopher must alternately think and eat. However, a philosopher can only eat spaghetti when he has both left and right forks. Each fork can be held by only one philosopher and so a philosopher can use the fork only if it is not being used by another philosopher. After he finishes eating, he needs to put down both forks so they become available to others. A philosopher can take the fork on his right or the one on his left as they become available, but cannot start eating before getting both of them.

Eating is not limited by the remaining amounts of spaghetti or stomach space; an infinite supply and an infinite demand are assumed.

The problem is how to design a discipline of behavior (a concurrentalgorithm) such that no philosopher will starve; i.e., each can forever continue to alternate between eating and thinking, assuming that no philosopher can know when others may want to eat or think. The problem was designed to illustrate the challenges of avoiding deadlock, a system state in which no progress is possible. To see that a proper solution to this problem is not obvious, consider a proposal in which each philosopher is instructed to behave as fol-lows:

 think until the left fork is available; when it is, pick it up;  think until the right fork is available; when it is, pick it up;  when both forks are held, eat for a fixed amount of time;  then, put the right fork down;

 then, put the left fork down;  repeat from the beginning.

(4)

{

enum {thinking, hungry, eating} state[5]; condition self[5];

void pickup(int i) // following slides void putdown(int i) // following slides

void test(int i) // following slides void init() {

for (int i = 0; i < 5; i++) state[i] = thinking; }

}

void pickup(int i) { state[i] = hungry; test(i);

if (state[i] != eating) self[i].wait(); }

void putdown(int i) { state[i] = thinking;

// test left and right neighbors 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(); }

}

b.

i. Explain the Paging and Segmentation Combined scheme.

Both paging and segmentation have their strengths. Paging, which is transparent to the programmer, eliminates external fragmentation and thus provides efficient use of main memory. Pieces that are moved in and out of main memory are of fixed equal size, it is possible to develop sophisticated memory-management algorithms that exploit the behavior of programs. Segmentation is visible to the programmer and has the ability to handle growing data structures, modularity, and support for sharing and protection. To combine the advantages of both, some systems are equipped with processor hardware and operating system software to provide both. In a combined paging/segmentation system a user address space is broken up

(5)

into a number of segments at the discretion of the programmer. Each segment is in turn broken up into a number of fixed-size pages which are equal in length to a main memory frame. If a segment is less than a page in length, the segment occupies just one page. From the programmer`s point of view, a logical address still consists of a segment number and a segment offset. From the system`s point of view, the segment offset is viewed as a page number and page offset for a page within the specified segment. Associated with each process are segment tables and number of page tables, one per process segment. When a particular process is running, a register holds the starting address of the segment table for that process. Presented with a virtual address, the processor uses the segment number portion to index into the process segment table to find the page table for that segment. Then, the page number portion of the virtual address is used to index the page table and look up the corresponding frame number. This combined with the offset portion of the virtual address to produce the desired real address. The segment table entry contains the length of the segment. It also contains a base field, which now refers to a page table. The present and modified bits are not needed because these matters are handled at the page level. Other control bits may be used for purposes of sharing and protection. The page table entry is essentially the same as that used in a pure paging system. Each page number is mapped onto a corresponding frame number if the page is present in main memory.

(6)

References

Related documents

The study included patients who were considered eligible for autologous and allogeneic peripheral blood haematopoietic stem cell transplantation by the clinical directors of the

• To perform virtual to physical address translation we need to look-up a page table.. • Since page table is in memory, need to

[r]

– page table entry contains page frame number (PFN) – physical address is PFN::offset. •

○ If BP elevated, think primary aldosteronism, Cushing’s, renal artery stenosis, ○ If BP normal, think hypomagnesemia, severe hypoK, Bartter’s, NaHCO3,

 With paging, physical memory is also split into some number of pages called a page frame..  Page table per process is needed to translate the virtual address to

DMTF shall have no liability to any party implementing such standard, whether such implementation is foreseeable or not, nor to any patent owner or claimant, and shall have

preferred represent bias scores calculated from the observers gaze. Bias scores represent the average viewing time of the non-preferred subtracted from the preferred viewing time.