SlideShare a Scribd company logo
1 of 8
Operating System
Engineering
Programming Homework Help Solutions
For any help regarding Programming Homework Help visit :
https://www.programminghomeworkhelp.com/ ,
Email - support@programminghomeworkhelp.com or call us at - +1 678 648 4277
I Traps/Interrupts
1.Draw a picture of the kernel stack after the following events have happened: (1) the icode program
has called the exec system call; and (2) a clock interrupt handler has interrupted exec() at line 3027;
and (3) the clock handler just finished executing line 3739? For each entry on the stack describe what
that entry represents. You may ignore local variables.
The kernel stack starts off empty. A system call must be the first thing on a trap frame at this point
— if any interrupts happened before, they would not have had any other process to switch to on the
return path.
in trap
in trap
in trap1
in exec
CLOCK interrupt
in clock
PSW from icode
PC of icode’s SYS instruction r0 of icode
PSW after trap (br7 + 6) r1 of icode
SP of icode
masked PSW after trap (6)
return address for call1 return (line 786) saved r5
saved r4 saved r3
saved r2
&cret
&exec (an argument to trap1) return address
in trap (line 2772) saved r5/r4/r3/r2 + &cret
return address in trap1 (line 2848) saved
r5/r4/r3/r2 + &cret
PSW from exec
PC from exec (line 3027) r0 from
exec
PSW after interrupt (br6) r1 from
exec
sp (same as sp now) masked
PSW
return address in trap (line 800) saved
r5/r4/r3/r2 + &cret
Programming Homework Help Solutions
2. Which kernel stack is the one you drew in response to question 1? Kernel stack 0?
Kernel stack 1?
Kernel Stack 1 is used. Process 1 (icode) was executing at the time of the trap and so its
kernel stack is used. If the machine is already in kernel mode when an interrupt happens,
the current kernel stack is used.
3. Can another clock interrupt interrupt the handler at line 3739? At line 3770?
At line 3739, another clock interrupt can not interrupt the handler: the priority of the
processor has been set to 6 already as a result of line 534 (or 535).
At line 3770, the interrupt handler has lowered the priority level to 5 so another clock
interrupt (at level 6) could interrupt the handler at this point.
4. Estimate how large a kernel stack must be to handle recursive traps and interrupts
correctly?
The kernel stack must be able to hold sufficient stack and trap frames for the most
recursive case. This occurs if a process executes a system call, receives a priority 4
interrupt, followed by a priority 5 interrupt, followed by a priority 6 interrupt, followed
by a re-entrant priority 6 interrupt.
In addition to the size of the trap frame (i.e. the arguments to trap), you would need to
consider stack frames generated by the deepest system call procedure call path (e.g. open
calls namei which calls . . . ; this is probably not too deep but might change as the kernel
evolved), the deepest interrupt 4 handler call path, etc.
From the figure, we can see that a system call trap requires 20 stack elements for the trap
frame and stack frames for the trap dispatch code (plus some extra for locals). Similarly, a
non-syscall trap requires 8 stack elements for the trap frame. Assume that the maximum
call depth for a function in the kernel is 4, where each stack frame requires 6 stack
elements (5 from csav, and an average of 1 argument). This gives a maximum depth of
approximately
Programming Homework Help Solutions
. Since each stack entry is two bytes, this gives a lower bound of 344 bytes. Of course, some
additional room will be needed to account for local variables, which were ignored for this problem.
II Coordinating threads
5.What do the statements at line 2088 and line 2092 do?
Line 2088 calls spl6() which sets the processor privilege level to 6. This causes all interrupts of priority less
than or equal to 6 to be ignored. Line 2092 calls spl0(), lowering the privilege level back to 0. These calls are
used to mark atomic sections.
6. Why are these statements needed? Give an actual sequence of events that will result in erroneous behavior
if these two statements are omitted. Your sequence of events should be as concrete as possible, not merely
hypothetical.
Programming Homework Help Solutions
1.runin++ on 1954
2.scheduler calls sleep on 1955 with runin as channel
3.executes lines 2089 setting p wchan to &runin
4.processor is interrupted by clock
5.clock interrupt handler sets runin to zero (3821)
6.handler calls wakeup with &runin as argument (3822)
7.wakeup calls setrun, which sets p wchan to zero and p stat to SRUN (2139–2140)
8.handler returns
9.now scheduler sets p stat to SSLEEP(2090)
10.and calls swtch
11.scheduler will never be woken up, because p stat == SSLEEP and p wchan is zero
Deadlock:
1.a user process calls indirectly bwrite(), which launches write on buffer.
2.then calls iowait,
3.which calls sleep with the address of the buffer as the channel
4.sleep sets p wchan (2089)
5.disk interrupt comes in completing the write of the buffer
6.it calls iodone, which calls wakeup on the buffer address
7.calls setrun, which sets p wchan to zero and p stat to SRUN
8.interrupt handler completes
9.process sets p stat to SSLEEP(2090)
10.and call swtch
11.process will never be woken up because p wchan is zero and p stat SSLEEP
Programming Homework Help Solutions
III Address spaces
7. Draw the prototype segmentation registers with their actual content after the call to estabur() on line 3152 has completed.
Assume that w0 is 410, w1 is 129, w2 is 32, and w3 is 128 (see lines 3076 through 3082). Explain the content of the registers
briefly.
Converting what we are given into blocks (and hence the arguments to estabur), we get:
text size is 129 bytes (w1 = 129) SSIZE
(stack size) = 20 blocks
==> nt = 3 blocks
==> ns = 20 blocks
data size is 160 bytes (w2 = 32, w3 = 128) ==> nd = 3 blocks USIZE = 16 blocks
That is, estabur(nt = 3, nd = 3, ns = 20, sep = 0).
Since each segment (8KB) contains 128 blocks, the text, data, and stack each fit within one segment:
+ + + + PAR[7]: |
-89 | PDR[1]: | 108 ED RW |
+ + + +
PAR[7] = USIZE + nd + ns - 128
= 16 + 3 + 20 - 128
= 39 - 128
= -89
PDR[1] = (128 - ns) << 8 | ED | RW
= 108<<8 | ED | RW
+ + + +
2 RW |
PAR[1]: | USIZE | PDR[1]: |
+ + + +
PAR[1] = USIZE = 20
PDR[1] = (nd - 1) << 8) | RW
= 2<<8 | RW
+ + + +
| 0 | PDR[0]: | 2 RO |
+ + + +
PAR[0]:
PAR[0] = 0, because at line 1675 a = 0 PDR[0] =
(nt - 1) << 8) | R0
= 2<<8 | R0
All other PARs and PDRs are cleared by lines 1694–1696.
Programming Homework Help Solutions
Why is “a-128” stored in the prototype segment for the stack? Explain your answer by showing how the virtual address 0177777 is
translated to a physical address.
At the point where “a-128” is written into PAR[7], “a” equals the combined sizes of the u area, data, bss and stack. A contiguous
region of physical memory (“a” blocks in size) is allocated to hold these components of the process.
+ +
| stack |
+ +
| data+bss |
+ +
| u area |
+ +
a blocks in size
Dividing the VA 0177777 into its constituent fields, APF:block number:block offset yields 7:127:63. Translation of this VA selects
PAR[7] which holds “a-128”. Added to this number is the block number, 127, resulting in physical block number “a-1”. The physical
address refernced is therefore “a-1”:63. But since the chunk of physical memory allocated was of size “a” blocks, this precisely refers
to the last byte (byte 63) of the last block (block “a-1”). This is where the first byte of the stack is located.
9. What happens if the processor executes the instruction “tst -(sp)”, and the user stack pointer falls below the stack segment? Write
down the names of the functions that v6 invokes in order.
A segmentation exception will result and the stack will grow (assuming free memory can be found). The following calls will be
made:
Machine generates exceptions
=> trap:
=> trap()
=> backup()
=> grow()
Then control returns back to the user process and it resumes execution where it left off, re-executing the ”tst -(sp)” instruction. The
second execution succeeds of course.
IV I/O and file systems
Why does the structure struct file exist? Why not have a file descriptor point directly to the incore inode structure, and store f offset in
it?
struct fileexists so that if two separate processes open the same file, they have their own offset pointer into it.
Programming Homework Help Solutions
11.Assume the directory “d” exists, that it is the current working directory, and that it has two entries
(including “.” and ‘”..”). If an application calls creat (“bar”, 0444), and the power fails right after the
processor completed the call wdir on line 7467, what is the state of the file system on disk? More
specifically, does the file “bar” exist on disk? Does the file “bar” show up in the directory “d” on disk?
The updated inode of directory “d” exists (because inodes are updated synchronously). The data of “d” may
not be written because v6 wrote it using bdwrite (it is a partial block). The file doesn’t exist yet, because we
haven’t gotten far enough yet into the creat call (maknode is called from line 5790).
Programming Homework Help Solutions

More Related Content

What's hot

Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in RustChih-Hsuan Kuo
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Chih-Hsuan Kuo
 
Datastage real time scenario
Datastage real time scenarioDatastage real time scenario
Datastage real time scenarioNaresh Bala
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in GeckoChih-Hsuan Kuo
 
Python programing
Python programingPython programing
Python programinghamzagame
 
Refactor case study LAN example
Refactor case study LAN exampleRefactor case study LAN example
Refactor case study LAN exampleTom Mens
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocationGrishma Rajput
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMarian Marinov
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data RepresentationWang Hsiangkai
 
LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)Wang Hsiangkai
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance PuzzlersDoug Hawkins
 

What's hot (20)

Computational Assignment Help
Computational Assignment HelpComputational Assignment Help
Computational Assignment Help
 
Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
Datastage real time scenario
Datastage real time scenarioDatastage real time scenario
Datastage real time scenario
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
 
Python programing
Python programingPython programing
Python programing
 
Refactor case study LAN example
Refactor case study LAN exampleRefactor case study LAN example
Refactor case study LAN example
 
Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data Representation
 
ocelot
ocelotocelot
ocelot
 
Ch7
Ch7Ch7
Ch7
 
Homework solutionsch8
Homework solutionsch8Homework solutionsch8
Homework solutionsch8
 
LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)LLVM Register Allocation (2nd Version)
LLVM Register Allocation (2nd Version)
 
Csharp_Chap13
Csharp_Chap13Csharp_Chap13
Csharp_Chap13
 
Python
PythonPython
Python
 
Java Performance Puzzlers
Java Performance PuzzlersJava Performance Puzzlers
Java Performance Puzzlers
 
Concurrency
ConcurrencyConcurrency
Concurrency
 

Similar to Operating System Engineering

General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareDaniel Blezek
 
Pipelining and co processor.
Pipelining and co processor.Pipelining and co processor.
Pipelining and co processor.Piyush Rochwani
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded ProgrammingSri Prasanna
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-optJeff Larkin
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored InterruptHardik Manocha
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Pluginsamiable_indian
 
pipeline and vector processing
pipeline and vector processingpipeline and vector processing
pipeline and vector processingAcad
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.pptJaya Chavan
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorialhughpearse
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploitshughpearse
 
Joblib: Lightweight pipelining for parallel jobs (v2)
Joblib:  Lightweight pipelining for parallel jobs (v2)Joblib:  Lightweight pipelining for parallel jobs (v2)
Joblib: Lightweight pipelining for parallel jobs (v2)Marcel Caraciolo
 
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovWorkshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovFwdays
 
Assembly programming
Assembly programmingAssembly programming
Assembly programmingOmar Sanchez
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.Rakib Hossain
 

Similar to Operating System Engineering (20)

General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics Hardware
 
Pipelining and co processor.
Pipelining and co processor.Pipelining and co processor.
Pipelining and co processor.
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded Programming
 
Sayeh extension(v23)
Sayeh extension(v23)Sayeh extension(v23)
Sayeh extension(v23)
 
May2010 hex-core-opt
May2010 hex-core-optMay2010 hex-core-opt
May2010 hex-core-opt
 
x86_1.ppt
x86_1.pptx86_1.ppt
x86_1.ppt
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
Lec05
Lec05Lec05
Lec05
 
pipeline and vector processing
pipeline and vector processingpipeline and vector processing
pipeline and vector processing
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.ppt
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Joblib: Lightweight pipelining for parallel jobs (v2)
Joblib:  Lightweight pipelining for parallel jobs (v2)Joblib:  Lightweight pipelining for parallel jobs (v2)
Joblib: Lightweight pipelining for parallel jobs (v2)
 
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovWorkshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
 
Assembly programming
Assembly programmingAssembly programming
Assembly programming
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Buffer overflow attack
Buffer overflow attackBuffer overflow attack
Buffer overflow attack
 
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.Exploring Parallel Merging In GPU Based Systems Using CUDA C.
Exploring Parallel Merging In GPU Based Systems Using CUDA C.
 

More from Programming Homework Help

Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpProgramming Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxProgramming Homework Help
 

More from Programming Homework Help (20)

C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Python Question - Python Assignment Help
Python Question - Python Assignment HelpPython Question - Python Assignment Help
Python Question - Python Assignment Help
 
Best Algorithms Assignment Help
Best Algorithms Assignment Help Best Algorithms Assignment Help
Best Algorithms Assignment Help
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Algorithms Design Assignment Help
Algorithms Design Assignment HelpAlgorithms Design Assignment Help
Algorithms Design Assignment Help
 
Algorithms Design Homework Help
Algorithms Design Homework HelpAlgorithms Design Homework Help
Algorithms Design Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Software Construction Assignment Help
Software Construction Assignment HelpSoftware Construction Assignment Help
Software Construction Assignment Help
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

Operating System Engineering

  • 1. Operating System Engineering Programming Homework Help Solutions For any help regarding Programming Homework Help visit : https://www.programminghomeworkhelp.com/ , Email - support@programminghomeworkhelp.com or call us at - +1 678 648 4277
  • 2. I Traps/Interrupts 1.Draw a picture of the kernel stack after the following events have happened: (1) the icode program has called the exec system call; and (2) a clock interrupt handler has interrupted exec() at line 3027; and (3) the clock handler just finished executing line 3739? For each entry on the stack describe what that entry represents. You may ignore local variables. The kernel stack starts off empty. A system call must be the first thing on a trap frame at this point — if any interrupts happened before, they would not have had any other process to switch to on the return path. in trap in trap in trap1 in exec CLOCK interrupt in clock PSW from icode PC of icode’s SYS instruction r0 of icode PSW after trap (br7 + 6) r1 of icode SP of icode masked PSW after trap (6) return address for call1 return (line 786) saved r5 saved r4 saved r3 saved r2 &cret &exec (an argument to trap1) return address in trap (line 2772) saved r5/r4/r3/r2 + &cret return address in trap1 (line 2848) saved r5/r4/r3/r2 + &cret PSW from exec PC from exec (line 3027) r0 from exec PSW after interrupt (br6) r1 from exec sp (same as sp now) masked PSW return address in trap (line 800) saved r5/r4/r3/r2 + &cret Programming Homework Help Solutions
  • 3. 2. Which kernel stack is the one you drew in response to question 1? Kernel stack 0? Kernel stack 1? Kernel Stack 1 is used. Process 1 (icode) was executing at the time of the trap and so its kernel stack is used. If the machine is already in kernel mode when an interrupt happens, the current kernel stack is used. 3. Can another clock interrupt interrupt the handler at line 3739? At line 3770? At line 3739, another clock interrupt can not interrupt the handler: the priority of the processor has been set to 6 already as a result of line 534 (or 535). At line 3770, the interrupt handler has lowered the priority level to 5 so another clock interrupt (at level 6) could interrupt the handler at this point. 4. Estimate how large a kernel stack must be to handle recursive traps and interrupts correctly? The kernel stack must be able to hold sufficient stack and trap frames for the most recursive case. This occurs if a process executes a system call, receives a priority 4 interrupt, followed by a priority 5 interrupt, followed by a priority 6 interrupt, followed by a re-entrant priority 6 interrupt. In addition to the size of the trap frame (i.e. the arguments to trap), you would need to consider stack frames generated by the deepest system call procedure call path (e.g. open calls namei which calls . . . ; this is probably not too deep but might change as the kernel evolved), the deepest interrupt 4 handler call path, etc. From the figure, we can see that a system call trap requires 20 stack elements for the trap frame and stack frames for the trap dispatch code (plus some extra for locals). Similarly, a non-syscall trap requires 8 stack elements for the trap frame. Assume that the maximum call depth for a function in the kernel is 4, where each stack frame requires 6 stack elements (5 from csav, and an average of 1 argument). This gives a maximum depth of approximately Programming Homework Help Solutions
  • 4. . Since each stack entry is two bytes, this gives a lower bound of 344 bytes. Of course, some additional room will be needed to account for local variables, which were ignored for this problem. II Coordinating threads 5.What do the statements at line 2088 and line 2092 do? Line 2088 calls spl6() which sets the processor privilege level to 6. This causes all interrupts of priority less than or equal to 6 to be ignored. Line 2092 calls spl0(), lowering the privilege level back to 0. These calls are used to mark atomic sections. 6. Why are these statements needed? Give an actual sequence of events that will result in erroneous behavior if these two statements are omitted. Your sequence of events should be as concrete as possible, not merely hypothetical. Programming Homework Help Solutions
  • 5. 1.runin++ on 1954 2.scheduler calls sleep on 1955 with runin as channel 3.executes lines 2089 setting p wchan to &runin 4.processor is interrupted by clock 5.clock interrupt handler sets runin to zero (3821) 6.handler calls wakeup with &runin as argument (3822) 7.wakeup calls setrun, which sets p wchan to zero and p stat to SRUN (2139–2140) 8.handler returns 9.now scheduler sets p stat to SSLEEP(2090) 10.and calls swtch 11.scheduler will never be woken up, because p stat == SSLEEP and p wchan is zero Deadlock: 1.a user process calls indirectly bwrite(), which launches write on buffer. 2.then calls iowait, 3.which calls sleep with the address of the buffer as the channel 4.sleep sets p wchan (2089) 5.disk interrupt comes in completing the write of the buffer 6.it calls iodone, which calls wakeup on the buffer address 7.calls setrun, which sets p wchan to zero and p stat to SRUN 8.interrupt handler completes 9.process sets p stat to SSLEEP(2090) 10.and call swtch 11.process will never be woken up because p wchan is zero and p stat SSLEEP Programming Homework Help Solutions
  • 6. III Address spaces 7. Draw the prototype segmentation registers with their actual content after the call to estabur() on line 3152 has completed. Assume that w0 is 410, w1 is 129, w2 is 32, and w3 is 128 (see lines 3076 through 3082). Explain the content of the registers briefly. Converting what we are given into blocks (and hence the arguments to estabur), we get: text size is 129 bytes (w1 = 129) SSIZE (stack size) = 20 blocks ==> nt = 3 blocks ==> ns = 20 blocks data size is 160 bytes (w2 = 32, w3 = 128) ==> nd = 3 blocks USIZE = 16 blocks That is, estabur(nt = 3, nd = 3, ns = 20, sep = 0). Since each segment (8KB) contains 128 blocks, the text, data, and stack each fit within one segment: + + + + PAR[7]: | -89 | PDR[1]: | 108 ED RW | + + + + PAR[7] = USIZE + nd + ns - 128 = 16 + 3 + 20 - 128 = 39 - 128 = -89 PDR[1] = (128 - ns) << 8 | ED | RW = 108<<8 | ED | RW + + + + 2 RW | PAR[1]: | USIZE | PDR[1]: | + + + + PAR[1] = USIZE = 20 PDR[1] = (nd - 1) << 8) | RW = 2<<8 | RW + + + + | 0 | PDR[0]: | 2 RO | + + + + PAR[0]: PAR[0] = 0, because at line 1675 a = 0 PDR[0] = (nt - 1) << 8) | R0 = 2<<8 | R0 All other PARs and PDRs are cleared by lines 1694–1696. Programming Homework Help Solutions
  • 7. Why is “a-128” stored in the prototype segment for the stack? Explain your answer by showing how the virtual address 0177777 is translated to a physical address. At the point where “a-128” is written into PAR[7], “a” equals the combined sizes of the u area, data, bss and stack. A contiguous region of physical memory (“a” blocks in size) is allocated to hold these components of the process. + + | stack | + + | data+bss | + + | u area | + + a blocks in size Dividing the VA 0177777 into its constituent fields, APF:block number:block offset yields 7:127:63. Translation of this VA selects PAR[7] which holds “a-128”. Added to this number is the block number, 127, resulting in physical block number “a-1”. The physical address refernced is therefore “a-1”:63. But since the chunk of physical memory allocated was of size “a” blocks, this precisely refers to the last byte (byte 63) of the last block (block “a-1”). This is where the first byte of the stack is located. 9. What happens if the processor executes the instruction “tst -(sp)”, and the user stack pointer falls below the stack segment? Write down the names of the functions that v6 invokes in order. A segmentation exception will result and the stack will grow (assuming free memory can be found). The following calls will be made: Machine generates exceptions => trap: => trap() => backup() => grow() Then control returns back to the user process and it resumes execution where it left off, re-executing the ”tst -(sp)” instruction. The second execution succeeds of course. IV I/O and file systems Why does the structure struct file exist? Why not have a file descriptor point directly to the incore inode structure, and store f offset in it? struct fileexists so that if two separate processes open the same file, they have their own offset pointer into it. Programming Homework Help Solutions
  • 8. 11.Assume the directory “d” exists, that it is the current working directory, and that it has two entries (including “.” and ‘”..”). If an application calls creat (“bar”, 0444), and the power fails right after the processor completed the call wdir on line 7467, what is the state of the file system on disk? More specifically, does the file “bar” exist on disk? Does the file “bar” show up in the directory “d” on disk? The updated inode of directory “d” exists (because inodes are updated synchronously). The data of “d” may not be written because v6 wrote it using bdwrite (it is a partial block). The file doesn’t exist yet, because we haven’t gotten far enough yet into the creat call (maknode is called from line 5790). Programming Homework Help Solutions