460 Review Questions
460 REVIEW QUESTIONS
1. BOOTER and LOADER (LAB #1 and LAB #2)
(1). During booting, what does BIOS do?
(2). Where in memory does BIOS load the boot SECTOR?
(3). What does the boot SECTOR do?
(4). HOW TO load a disk block into memory?
(5). When a boot program runs, why are CS,DS,SS set to the same value?
(6). How to convert a disk block number into (cyl,head,sector) for BIOS?
(7). A complete a.out file has a header. What are in the header?
(8). After loading a (complete) a.out to a segment, WHY do you have to
MOVE it upward 32 bytes?
(9). The BSS section of a loaded image is usually cleared to 0: WHY and HOW?
2. Multitasking (LAB #3)
A process is the execution of an image, which consists of
|CODE | DATA | STACK|
(1). In the MTX kernel, there are many READY procs and ONE running proc.
What are the images of the procs in KERNEL? i.e. identify the
CODE, DATA and STACK
of each proc.
(2). IT was said many times in the lecture that a new proc is created in such
a way that
AS IF IT RAN BEFORE AND IT GAVE UP CPU by calling tswitch() from
some location.
So, how to create a new proc to make it begin to run from a location
named HERE?
(3). The stack contents of a READY proc depends on the (assembly code) of
tswitch:
SAVE: push ax,bx,cx,dx,bp,si,di,flag
and RESUME: which pops SAVED values into CPU registers.
IF the SAVE part is modified, e.g. with out push ax,
WHAT should be the RESUME part?
LIKEWISE, if the SAVE part has more pushes, what should be the RESUME part?
(4). If a proc is running, what are its stack contents?
(5). How does a task "give up" CPU ? What actions does it take while
"giving up CPU"?
(6). sleep()/wakeup(): How do these work?
pid = wait(exitValue): What does it do? HOW (wait logic)?
3. Syscall Calls: (LAB # 4)
(1). What does the instruction INT 80 do?
(2). What's an interrupt vector? Speciffically, in order to let a proc
execute INT 80, what must be in the interrupt vector 80?
(3). HOw does a proc enter Kmode (via syscall)?
(4). To create a proc with a Umode image, we
PRETEND THAT THE proc DID AN INT 80 IN UMODE FORM ITS VIRTUAL
ADDRESS 0.
According to OUR int80h() assembly code,
_inth0h: push ax,bx,cx,dx,bp,si,di,ES,DS
change to DS,SS,ES to Kmode's segment, sp=running's kstack
save uSS, uSP into PROC.uss, PROC.usp
call _kcinth in C
_goUmode: restore save uSS, uSP from PROC
pop DS,ES,di,si,bp,dx,cx,bx,ax
iret
So, what are in ustack of a newly created proc?
(5). When a proc calls syscall(a,b,c,d) to enter Kmode,
how can it find out the values of a,b,c,d from Kmode?
(6). Every syscall function returns a value, e.g. pid = fork();
How to return a value from Kmode to Umode?
(7). Uspace and Kspace are 2 DIFFERENT address spaces.
How to transfer bytes or words between Uspace and Ksapce?
HOW did you implement the chanme("new proc name") system call?
How to implement getProcName(char name[64]) syscall, which allows a proc
to get its own name string to Umode?
(8). fork() and exec() from Umode:
HOW DO THEY WORK?
4. INTERRUPTS and INTERRUPT HANDLER:
(1). Refer to the INTERRUPT SETUP diagram in Notes#6:
.Why do Timer interrupt at IRQ0 and keyboard at IRQ1?
.When both Timer and keyboard interrupt at the same time, which
interrupt goes to the CPU first?
.When does the CPU actually serve the interrupt?
(2). An IRQn interrupt request acts like an INT N instruction to the CPU.
What's the relation between n and N?
(3). Refer to the INTH macro in assembly, a Timer interrupt handler can be
installed in our MTX by
_tinth: INTH thandler
WHAT DOES (the expanded code) of INTH do?
(4). It is NECESSARY to know whether an interrupt occured in Kmode or in Umode.
WHY? HOW?
5. Display, Timer and Keyboard Drivers:
(1). In the display driver, how does it putc(char c) onto the screen?
How does scrow() one row, work?
How to implement a scrowDown(), which scrows the screen DOWNWARD one row?
(2). With the display driver, our MTX no longer needs putc() by BIOS.
How to display chars from Umode?
(3). In the Timer LAB assignment:
Timer interrupts once every tick=1/60 seconds. How did you
display hh:mm:ss
at each second at the LOWER-RIGHT corner of the screen?
(4). Every proc may run in Umode for 5 seconds. A proc running in Umode is
switched out if its running time expires. HOW did you implement this?
WHY switch process in Umode only?
(5). A proc may request PAUSE(int n) to stop running for n seconds.
It becomes READY to run again after n seconds.
HOW TO IMPLEMENT this in our MTX?
(6). Refer to the DEMO keyboard driver code.
.how does the interrupt handler get a key's scan code from the hardware?
.how does it know whether it's a key PRESS or RELEASE?
.how does it translate a key PRESS to an ascii char value?
The DEMO keyboard driver works as follows.
It uses a int kbc to hold the key value and a int kbdata <- 1 to
indicate there is a key in kbc.
A proc calling getc() uses while(kbdata==0); to wait for a key.
It has severl flaws:
(1). A proc calling getc() BUSY waits for any key. HOW TO eliminate the
BUSY wait (i.e. do NOT use while(kbdata==0); loop?)
(2). kbd can hold ONLY ONE key. HOW TO allow many input keys?
(7). When a key is pressed, if the interrupt handler finds kbdata still 1
(which means that the last key in kbc has NOT been gotten by a proc)
it should NOT put the current key into kbc (so as not to overwrite the
the previous key), so it does
sleep(&kbdata);
to wait for kbdata = 0. WHAT's WRONG and WHY?