Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
1. What happens to a thread when it exits (i.e., calls thread_exit())? What about when it Answer: Briefly when a Thread calls calls thread_exit(),then thread_exit(),then thread_exit() will set interru avoid race condition condition with context switch and then will save current current threads vmspace next threads as null, manipulate(decrement) the refrence counts and add the thread zombies's list, we dont actullay destroy all its resources, it will be done by thread_destro
When thread calls thread_sleep it sets the address of the current thread thread as sleepaddr(sleep_address)and sleepaddr(s leep_address)and then gives a call to machinde independent independent context switch routine( Which in turn gives call to machine dependent switch which calls mips_switch sets sleep address of current thread as null
2. What function(s) handle(s) a context switch? Answer: There are functions at different level and interleaved that handle the context From thread.c we give call to static void mi_switch(threadstate_t nextstate) which is m independent independ ent call to context switch that in turn gives a call to void md_switch(struct md_switch(struct p struct pcb *nu) which is machine dependent call to handle context switch that in turn mips_switch(struct mips_swi tch(struct pcb *old, struct pcb *nu), this is the real function at system level t actually does the switch. At each level data structures such as data references and cu thread and stack , interrupt are manipulated
Master your semester with Scribd Free Foron 30this Days Sign up to vote title 3. How many thread states are there? What are they?Read & The NewAnswer: YorkThere Times Useful Not useful are 4 thread states that are defined in thread.c as enum data structure Special offer for students: Only $4.99/month.
Cancel anytime.
namely run,ready,sleep,zombie. run,ready,sleep,zombie. Following is the structural defination:
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
kernel code, so that it is uninterrupted execution moreover, it also allows us to aviod condition if there is a shared variable. Thereby making the execution safe. It is accomplished using splhigh() function that sets interrupt off.
It is important to turn interrupts off especially in thread code so that race conditio avoided when updating the shared variable such as refrence counts, numberof with for example context switch which will try to manipulate the same data at the time . Also to ensure atomicity of the execution as well as in to avoid thread sleeping while h interrupts.
5. What happens when a thread wakes up another thread? How does a sleeping thread g run again?
Answer: When a thread wakes up another thread than it passes the address of the thr that it wants to wake up. thread_wakeup() is invoked which will wake up that thread and chan stated to runnable. You're Reading a Preview
The calling thread than has to call yeild the cpu to thread but stay runnable using ca Unlock full access with a free trial. thread_yeild(void) Download With Free Trial
6. What function is responsible for choosing the next thread to run? Answer: We call scheduler() to determine the next thread to run which in turncalls v Read Free Foron 30this Days Sign up to vote title all t q_remhead(struct queue *q), which returns nothing but next in runqueue and sets Not useful Useful Cancel anytime. structures. Special offer for students: Only $4.99/month.
Master your semester with Scribd & The New York Times
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
finished for that process in executing, hardclock timer interrupts are generated indica quanta expiartion(interrupts every Hz value) and context switch happens.
On timer interrupt, static void mi_switch(threadstate_t nextstate) is called which is ha independent function.
9. Describe how thread_sleep() and thread_wakeup() are used to implement semaphores. the purpose of the argument passed to thread_sleep()? Answer: While using thread_sleep() in tt3.c we have simply disable interrupts and in thread_wakeup() we have used semaphores P and V so that mutual exclusion is achiev shared variable wakersem, is tested and set using P and V one and only one thread ca execute the instructions of setting the “done” variable at one time. Once a process u “done: it can release the lock the wakersem and starts its execution. While updating
“done” no other can set it and thus only one thread can execute it at one time. Hen
providing the desired functionality You're Reading a Preview is not interpreted as addres The purpose of argument passed to thread_sleep() Unlock full with a free trial. primitives or data structure thread rather it's the address ofaccess a synchronization Download With Free Trial
10.
Why does the lock API in OS/161 provide lock_do_i_hold(), but not lock_get_ho
Answer: We use lock_do_i_hold() to first check if other thread is holding the lock inste straight giving lock_get_holder() because we dont want the lock to be hold when other has got access to it else it will defeat the purpose ofRead mutual which Free Foron 30this Days Sign up to exclusion vote title is one of Not useful Useful reason that locks are implemeted. Cancel anytime.
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Below is the precise condition mentioned in os161 for locks:
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
Now two threads are waiting for keyboard input, one in each process. Does this probl occur in single-threaded processes? Answers: Yes, this problem will still occur in single threaded process, as it is created parent process in the same manner as in mutithreaded process ie parent process forks process and if design of operating system provides guideline that child process to be restricted to the parent process resources and inherit them which is our above case t even in single threaded process both the parent and child will wait for the same input child uses exec to load a different binary and that child process can fork even in waiti However, this can be solved by changing the design guidelines and inheritance of operating system
12. In a block/wakeup mechanism, a process blocks itself to wait for an event to o Another process must detect that the event has occurred, and wake up the blocked p It is possible for a process to block itself and wait for an event that will never occur. 1. Can the operating system detect that a blocked process is waiting for an event will never occur? 2. What reasonable safeguards might be built into an operating system to prevent You're Reading a Preview processes from waiting indefinitely for an event? Answer:Yes it is possible for a Unlock process to block But operating system should nev full access with aitself free trial. allow a currrely running process to block itself as block it will cause operating Download With Free and Trialos has no idea about its waitin to freeze(as it is the current execution can do so by first doing context switch and then changing its state to sleep/waiting)resulting in either panic code execution if os has its implemet In the later case where it does context switch os will never know result waiting. When scheduler calls kil_all itRead willupFree simply the process Forkill 30this Days Sign to vote on title loss of data/unrelaible/undesirable behaviour system. Usefulof operating Not useful
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Cancel anytime.
1.Operating system(OS161) cannot detect such waiting. However it is possible to det
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Sign In
Upload
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
13. Can two threads in the same process synchronize using a kernel semaphore if threads are implemented by the kernel? What if they are implemented in user space? no threads in any other processes have access to the semaphore. Discuss your answe Answers:Yes,if two threads in same process implemented by kernel can access kernel semaphores. However, if they are user threads then they cant access the kernel sema
14. In a system with threads, is there one stack per thread or one stack per proce user-level threads are used? What about when kernel-level threads are used? Explain Answers: There is a one stack per thread for each user level thread and Every thread both a user-mode stack, but they also have a kernel-mode stack that’s used when th in kernel mode, for example while executing system calls.(However, there is kernel sta process as well which we initialize in our fork code)
15. Five batch jobs, A through E, arrive at a computer center at almost the same They have estimated running times of 10, 6, 2, 4, and 8 minutes. Their (externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest prio You'realgorithms, Reading a Preview For each of the following scheduling determine the mean process turnarou Ignore process switching overhead. Unlock full access with a free trial. 1. Round robin Download With Free Trial 2. Priority scheduling 3. First-come, first-served (run in order 10, 6, 4, 2, 8) 4. Shortest job first Answer:Considering all process arrive at the same time: quata? Read Free Foron 30this Days Sign up to vote title
Master your semester with Scribd & The New York Times Special offer for1. students: Only $4.99/month. Round Robin With time
Quantum = 1 minute
Not useful Cancel anytime.
Useful
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks
Save
Embed
Share
Print
ch5
1
Download
Magazines
News
Documents
Sheet Music
Join
| b 0
| 6
e
| 14
a
of 8
| c 24
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
| 26
Search document
d
| 30
Mean turnaround time = 6+14+24+26+30/5 = 20
3.fcfs | a | b 0 10
| d 16
| c 20
| 22
e
| 30
Mean turnaround time = 10+16+20+22+30/5 = 19.6 4.sjf | c 0
| 2
d
| 6
b
| 12
e
| a | a Preview 20You're Reading 30 Unlock full access with a free trial.
Mean turnaround time = 2+6+12+20+30/5 = 14 Download With Free Trial
Master your semester with Scribd of the 16. For each of the following scheduling algorithms, major failing Read Free Foraon 30 Days Sign describe up to vote this title if appropriate provide a pathological example & The Newalgorithm York and Times Useful that Not useful this failing illustrates Special offer for students:1. Only $4.99/month. First come first
served 2. Shortest job first
Cancel anytime.
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks Magazines
News
Documents
Sheet Music
Save
Embed
Share
Print
Download
Join
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
Starvation is possible, especially in a busy system with many small processes being run.
Waiting time and response time increase as the process' computational requirements increas turnaround time is based on waiting time plus processing time, longer processes are significan affected by this. Overall waiting time is smaller than FIFO, however since no process has the termination of the longest process. 3. Priority algorithm:
Waiting time and response time depend on the priority of the process. Higher priority proces have smaller waiting and response times. .
Starvation of lower priority processes is possible with large amounts of high processes queuing for CPU time.
You're Reading a Preview Unlock full access with a free trial.
Download With Free Trial
1.Passing arguments from one user program, through the kernel, into another user program, of a chore. What form does this take in C? This is rather tricky, and there are many ways to astray. You will probably find that very detailed pictures and several walk-throughs will be m Read Free Foron 30this Days Sign up to vote title helpful. Not useful Useful Cancel anytime. Special offerAnswer: for students: Only $4.99/month. There are several ways to do it in c
Master your semester with Scribd & The New York Times
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join
Search
Home
Saved
202 views
0
Upload
Sign In
RELATED TITLES
0
Ass2 Answers Uploaded by Neha Patil
Top Charts
Books
Audiobooks
Join
Save
Embed
Share
Print
Download
ch5
1
of 8
solutionmanualofoperatingsystembysilbe process priority 160530051851.pdf in unix
Search document
Magazines
News
Documents
it may lead to performance penalty and diminsh the same.
Sheet Music
Moreover, we have to maintain atomicity of these operation as race condition might happen a or more threads might try to call the same functionality. 3.How will you determine: (a) the stack pointer initial value; (b) the initial register contents; return value; (d) whether you can exec the program at all? Answer: (a) the stack pointer initial value = value at address 0x80000000 (b) the initial register contents = Prior to main() mips-crt0. S has all initial register contents as execption.S has the same info but it changes less registers . (c) the return value = v0 returned from crt0 in mips-crt0 to main (d) whether you can exec the program at all = no
4.What new data structures will you need to manage multiple processes? Answer: Process Structure that will take care of exit codes and pids of process and there associated all child pids. You're Reading a Preview
5.What relationships do these new structures have with the rest of the system? Unlock full access with a free trial.
Answer: It will help the system to allow multiprocessing and context switching among them as as keeping there track. Download With Free Trial
6.How will you manage file accesses? When the shell invokes the cat command, and the cat command starts to read file1, what will happen if another program also tries to read file1? Wh would you like to happen?
Master your semester with Scribd Free Foron 30this Days Sign up to vote title Answer: We can manage file access by access control list Read & The New York Times Useful Not useful will lead toOnly race condition Special offerItfor students: $4.99/month. neither locking.
Cancel anytime. in os161 as os161 doesnt support file access control as of yet an
Home
Saved
Top Charts
Books
Audiobooks
Magazines
News
Documents
Sheet Music
Master your semester with Scribd & The New York Times Special offer for students: Only $4.99/month.
Upload
Sign In
Read Free For 30 Days Cancel anytime.
Join