-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
40 lines (23 loc) · 2 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
project 1:
idle thread could switch to running directly from blocked state
printf and other heavy-weight stuff could break timer's timing on alarm testing
disable interrupt and restore is often used to have lock and unpreemption
timer_sleep () could have negative input ?? not sure why
printf is problematic before console intialized. So, no printf will work correctly in objects used by console, for example, locks !!!!!!
for semaphore/lock priority, if no waiters, need to return PRI_MIN
when release lock, restore priority needs to be careful: if no other holding locks; if there are other locks while they dont have waiters
when to update waiting_lock: only in lock_acquire. before getting it, update, after getting it, reset to NULL
when to update holding_locks: acquire / release
carefully order updates and thread operations: thread operations will do context switch, so update might not take effect
3 lists we care for scheduling: ready_list, semaphore's locks, thread's holding_locks
ready_list needs to be ordered: next_to_run () always return the front one
waiters needs to be ordered: samaphore/lock's priority comes from waiter's highest priority
holding_locks dont need to: we use find_min(max) to get the highest priority lock
project 2
1. high level thing:
for each user program/process, it will be initiated by a kernel thread, usually go through steps like:
call process_wait -> onto a process_execute (), which triggers process_start() and in program, it makes system call sys_exit () to exit thread as well as exit process (process_exit ())
in in process_execute, new thread will be created. and in process_wait, it is in parent thread, it will remove the child user thread from its list and so on
2. sys_exit will set process status, by pass in a status from program itself. e.g. sys_exit (-1)
3. process_wait needs to return process_status, so free proc in process_wait until status bein captured
what if parent thread does not call process wait, ??? ?? then we dont free the resource ???