1.2
the current date.
(or prints) Result is -1
1.3
0x02220008
(Page directory)2 (Frame 2)3
1.4
maximum 100cylinker * 5ms + 10ms + 2K / (10sector * 1K / 10ms) = 512ms
average 1/3 * 100 * 5ms + 1/2 * 10ms + 2 / (10 * 1 / 10) = 173.67ms
1.5
use shortest job first.
the sequence of execution is c,a,d,b
average turnaround time is (3+7+16+28)/4 = 13.5s
1.6
the system seems responds more quickly.
more time are wasted to context switch.
lower effetive rate of CPU speed
1.7
4 4 2 3 4
3 4 2 3
2 4 2 3
1 1 2 3 5
1 1 2 3
0 1 2 0 6
0 1 2 0
1 1 2 0
2 1 2 0
4 1 2 4 7
1.8
each frame size 4K
each page table entry size 4Bytes
1MB requires 1 page directory entry and 1MB/4KB = 28 page table entries,
that it is, one page directory and one page table.
100 processes require one page directory and 100 page tables.
the total memory needed for the page tables is 101*4KB = 404KB
if each process has another 1MB, then the memory required is 404KB
1.9
if granularity bit is set to 0, the granularity of the limit value is
Byte. The limit is as describe in limit field of GDT/LDT in the unit of
Byte. If granularity bit is set to 1, the granularity of the limit value
is 4K. The limit is 4K times the number in the field of GDT/LDT in the
unit of Byte.
1.10
expected 0.99 * 5ns + 0.01 * 0.9999 * (50 + 5)ns + 0.01 * 0.0001 *
(50ns+5ns+5ms)
maximum 50ns + 5ns + 5ms
2.1
processes a and b are created.
the output of a is piped to the input of b and the output of b is
indirected to file c
the interprete first creat a pipe between a and b.
the it fork a new process and redirect the STDOUT of the new process to
one end of the pipe and execute a by calling execlp("a","a",NULL) (or
something else similar). In the meantime, the original process redirects
its STDIN to the other end of pipe and creates another new process by
calling fork. The new child process redirects its STDOUT to file c and
executed program b.
2.2
Apache
while (TRUE) {
socket = accept(...);
if (OK) {
if (fork()==0) {
process(socket);
close(cocket);
}
}
}
3.1
credit -> available resource
customer -> process
agreement -> the system allocat some resources to a process.
loan -> resource that owned by the process
borrowing -> requesting for new resource
limit -> enough resources that is kept to fully supply any process.
repayment -> deallocating resource.
......................................................................
......................................................................
3.2
1 decreaseing mutex to avoid two processes entering CS
simultaneously, or put the process to sleep if one process is in its CS
2 indicates the current philosopher is thinking. That it is, it
releases the resources which may be required by other processes.
3 4 test whether the current philosopher's neighbors are hungry
(requiring resources). If so, it sets that the processes can possess the
resource and wake them up if they sleep.
5 leaving CS.
对书中P60的代码不是很熟悉它具体是怎么运行的.其他人知道的请说一下.
4.1
for segmentation
the OS allocats GDT/LDT for each process when the process is first
executed (when the CPU works in protected mode). In context switch, the
os loads the corresponding GDT/LDT into the memory of the process if
it's not in the memory, and puts the GDT/LDT address in GDTR or LDTR
registers.
The OS also responds to some interrupts such as the offset beyond the
limit, the segment not present and so on.
the OS deallocates the GDT/LDT when the process terminates
the paging
the OS must allocate page tables for processes and add new entries into
page tables for each process before they execute.
The OS evicts page from second storage if the page is not in memory, and
choose one frame to swapped to the second storage to make room for the
needed page.
The OS must remove page entries if the process terminates.
4.2
advantage of having virtual address space larger than physical address
space: the process needing more memory than physical memory can run.
the disadvantage: the whole image of the process can't be loaded into
the memory and page faults happen frequently to slows down the execution.
advantage of having virtual address space smaller than physical address
space: The whole image of the process can be loaded into the memory and
thus reduce page faults.
disvantage: it confines the size of the process to the size smaller than
physical memory.
4.3
LRU, NFU, clock ????
prefetch
5.1
disk arm schuduling,cache and organization of disk to improve speed.
RAID to improve both speed and safety
5.2
1 efficience.
for the small size files, all the block numbers can be read from memory
after the inode structrue is loaded into the memory, reducing the time
because disk reading is no necessary.
2 size of the file
because i_block[] has one-layer, tow-layer, three-layer indircetion
structures for accessing the data blocks. Thus it makes it possible that
the file can be very large and i_block[] can still point out where the
blocks are via indirection structures
3 random access to file.
since all the block number are directly or indirectly indicated by
i_block[], it is fast to locate a certain block when the file is random
accessed.
limitation
the structure may take up much space in small partition.
6.1
Huang Maoliang 写道:
1.2
If not successful, there should be two lines of Result -1?
1.3
0x02220001 (I think the last three digits 0x007...means that it is valid)
1.8
"1MB requires 1 page directory entry and 1MB/4KB = 28 page table entries"...
1M / 4K = 2^20 / (4 2^10) = 2^8...not 28...
but still, each process needs a page directory and a page table...which are
8K in all.
So 100 processes need 800K...
if each process has another 1MB, we need another page table...so totally
1200K...
2.2
while (TRUE) {
socket = accept(...);
if (OK) {
if (fork()==0) {
process(socket);
close(cocket);
---- I think here we need exit(0); to terminate the child process ---
}
}
}
3.1
bank : OS :)
4.1
GDT is shared by all programs...Each process has its own LDT
4.3
dirty bit and some page replacement methods...
5.1
RAID to improve both speed and safety
5.2
I think for small files...EXT2 is not so good as FAT(the linked
list)...because you need to two disk operations to get a file...
while (TRUE) {
socket = accept(...);
if (OK) {
if (fork()==0) {
process(socket);
close(cocket);
---- I think here we need exit(0); to terminate the child process ---
}
}
}
I think what we need is wait(). exit(0) just exit not waiting for the
child process terminating, but in that case, the child's new father
process will be init;
Li, Yi 写道: