CS2106 2002 –A

1 view
Skip to first unread message

guozhang wang

unread,
Nov 23, 2006, 11:41:37 PM11/23/06
to hexakios

CS2106   2002 –A

 

1.1

D

 

1.2

B

 

1.3

B

 

1.4

Because when the OS sends lines of characters to the video display it needs very quick response when the data are ready, the interrupted driven mechanism using blocking can not meet this needs, a pooled driven mechanism using busy waiting may be more proper.

 

1.5

2 ms

 

1.6

60 * 5 * 1/3 + 2ms + 10/2 + 1/160 * 10 = 107.0625 ms

 

1.7

59 * 5 + 2 + 10 + 10 = 317 ms

 

1.8

It loads the whole file from the kernel memory space to the user memory space, and updates the relevant page tables for the process to access the file content.

 

1.9

5 * 0.99 + 75 * 0.01 * 0.9999 + 5075 * 0.01 * 0.0001 = 5.705

 

1.10

5

 

1.11

0, 2, 7

 

1.12

7, 0, 2

 

1.13

Say a process at level Normal is created, and at the same time a RealTime FIFO is created and at each time interval of the timer there creates a new RealTime FIFO process, therefore the scheduler will never choose the Normal process.

 

1.14

3

 

1.15

0

 

1.16

 

 

2.1

First process does a read: x->s, s = 0; then jumps to another process to run to the end, and then jumps back to first one doing a wirte: x<-s+1 = 1, then doing so 99 times, got min = 100;

 

First on do a read, then jumps to second one do the instruction 99 times, then jumps back and do the wirte: x = 1,   then first one run to the end: x = 100, then second one do the last time instruction: x = 101 = min + 1

 

2.2

When a RUNNING process is interrupted or makes a system call, it changes to BLOCKED;

When a BLOCKED process got the signal it waits or the resources it changes to READY;

When a quantum of the RUNNING process is run out, it changes to READY, and probably another READY process changes to RUNNING.

 

2.3

Not valid, process1 and process2 can still be at the CS at same time if we signaled process1 10ms ago and signaled process2 200 ms ago and then give no signals to them

 

3.1

Say there are 5 philosophers, then there can be such results: one philosopher have two neighbors keep picking up forks and eating alternatively, so every time he checks, if his left hand side neighbor is just about to put forks, his right hand side neighbor is eating, and vise versa, so he will see desperately his neighbors alternatively eating, using one of his forks and keep starving.

 

3.2

Need not be protected, because the current variable is only accessed by the scheduler, and there is only one scheduler as the question imply, so it can only be accessed and modified by one process, in other words there will be only one process in this CS all the time.

 

4.1

The OS will use the first 10 bits of the linear address as the index in the page directory to find the entry in it pointing to the page table, OS will check the attribute bits of the entry to see whether the page table is valid or not; If it is, OS will us the middle 10 bits as the index of the specific page table fetched to find the entry in it, it will check its attribute bits to see whether the page is in the memory (present) or not; if it is , the OS will add the last 12 bits of the linear address to the entry's upper 20 bits to generate the physical address.

 

5.1

If(p > c) pt = (p-c) * x;

Else pt = (c-p) * x + y;

Nt = (n-c) * x;

If(nt > pt)return true;

Else return false;

 

5.2

1) for security and stability

2) this will limit the file size to a smaller digit, which is unacceptable.

3) this will slow the searching speed dramatically because it will add disk access operations.

 

5.3

a) 1111 1110 0000 0000 0000

b) 1111 1111 1111 1100 0000

c) 1000 0001 1111 1100 0000

d) 1111 1001 1111 1100 0000

 

5.4

Who knows?

 

6.1

Int I;

If((I = fork()) == 0){

       Exec(func, arg, 0);

       Printf("exec() error!\n");

}

Else{

       Waitpid(I,0,0);

}

 

6.2

 

6.3

 

7.1

1) the size of the i_block structure is enlarged, and the maximum file size is enlarged one block per one increase on pointers, therefore the limit line (file size) of slower search speed is increased, but with same expense of the space of pointers

2) the limit line (file size) of slower search speed is decreased, but the size of the i_block is decreased also.

 

We need a trade-off between space consuming and time efficiency, considering most of the files is not so large than, say, 1MB, so the number direct pointers need not to be very big.

 

7.2

Hard links: the hard link file contains the exactly same inode number as the original file, so it only need one operations, just as the original file needs to access the file content.

Symbolic links: the symbolic link files contains a different inode number, but the data block of the file contains the file path/name of the original file, so OS can using this to get the inode number of the original file, this needs one more operations of the disk.

 

 

 

 

 

 

 



--
Computer Science and Engineering Department
Information Technology School
Fudan University,  200433
ShangHai
China.P.R
Reply all
Reply to author
Forward
0 new messages