CSCE 313 Quiz 2

True/False Questions [10 pts]

1. After handling a fault successfully, the CPU goes (when it does go back) to the instruction immediately after the faulting one

2. Interrupts are asynchronous events

3. Memory limit protection (within a private address space using base and bound) is implemented in the hardware instead of software

4. Memory limit protection checks are only performed in the User mode

5. Translation Look-aside Buffer (TLB) is a cache for popular (i.e., recently used) page table entries

6. Divide by 0 is an example of a fault

7. Every process has its own page table

8. A process cannot access its own page table

9 Trap is a type of synchronous exception

10. Faults are unintentional but possibly recoverable

11. [10 pts] Which of the following are privileged operations allowed only in Kernel mode?

  1. Setting 0 to a large chunk of memory (i.e., using the memset function)
  2. Modifying the page table entries
  3. Disabling and Enabling Interrupts
  4. Using the "trap" instruction
  5. Directly accessing I/O devices
  6. Handling an Interrupt
  7. Issuing a system call
  8. Changing the processor’s execution mode to User mode
  9. Divide by zero
  10. Clearing the Interrupt Flag

Short Questions

12. [5 pts] Why is the process state (i.e., PC, SP, EFLAGS, general registers) kept in the Kernel Interrupt Stack before handling an Interrupt? Why could we not store it in the user memory? What is the risk?

13. [5 pts] Describe the attack scenario of how an interrupted process can manipulate the process state in the above question. Note that this is from the Textbook 1 – we did not discuss this in class.

14. [5 pts] While implementing the process state diagram, what is the problem of having only 1 queue for all blocked processes waiting for all events? What is the solution to this problem? Describe with an example.

15. [5 pts] What is the difference between the "New" state and the "Ready to Run" state in the process state diagram?

16. [5 pts] Is a transition from the "Blocked" state to directly to the "Exit" state possible in the process state diagram? How?

17. [5 pts] Assume that the following physical memory is full with already allocated 5 pages as shown below (i.e., it is 20KB in capacity). Describe what happens if process 2 wants to allocate and use another page. What changes in the page tables and the physical memory?

a) [10 pts] The following are steps in a “sequential” Interrupt handling. What changes would you make in the steps below so that “nested” Interrupts can be handled?

Hardware does the following:

1.      Mask further interrupts

2.      Change mode to Kernel

3.      Copy PC, SP, EFLAGS to the Kernel Interrupt Stack (KIS)

4.      Change SP: to the KIS (above the stored PC, SP, EFLAGS)

5.      Change PC: Invoke the interrupt handler by vectoring through the Interrupt Vector Table (i.e., overwrite PC with the handler PC)

Software (i.e., the handler code) does the following:

1.      Stores the rest of the general-purpose registers being used by the interrupted process

2.      Does the rest of interrupt handling operation?

(b) [3 pts]: Can you interchange steps 2 and 3? Why or why not?

(c) [2 pts]: Can we interchange step 1 with step 2? Why or why not?

19. [20 pts] (a) Write the steps in a system call to read a byte from the keyboard. Refer to page 31 of Lecture 05 as a starting point. However, note that this will require more steps because the user may not type anything in the keyboard immediately. What is the state of the process while it is waiting for the keyboard input? How does it come back to the CPU? Discuss with the help of Process State Diagram.

(b) Now repeat the above when the user presses Ctrl+C from the keyboard without providing a valid input? How does this process navigate the process state diagram?

20. [15 pts] What is the output of the following program? Assume that the first processes pid=x, and every subsequent process’s pid increases by 1, because that is how usually PIDs are assigned. Explain the output that you observe after running the program using a diagram.

#include <stdio.h>

#include <sys/types.h>

#include <unistd.h>

void main (){

    for (int i=0; i<3; i++)

        fork();

        printf ("PID: %d\n" getpid());

        wait ();

    }

}

hihi

Cite This work.

To export a reference to this article please select a referencing stye below.

Assignment Hippo (2021) . Retrive from http://www.assignmenthippo.com/sample-assignment/csce-313-quiz-2

"." Assignment Hippo ,2021, http://www.assignmenthippo.com/sample-assignment/csce-313-quiz-2

Assignment Hippo (2021) . Available from: http://www.assignmenthippo.com/sample-assignment/csce-313-quiz-2

[Accessed 27/02/2021].

Assignment Hippo . ''(Assignment Hippo,2021) http://www.assignmenthippo.com/sample-assignment/csce-313-quiz-2 accessed 27/02/2021.


Want latest solution of this assignment

Want to order fresh copy of the Sample Template Answers? online or do you need the old solutions for Sample Template, contact our customer support or talk to us to get the answers of it.


+ Submit Your Assignment Here

AssignmentHippo Features

On Time Delivery

Our motto is deliver assignment on Time. Our Expert writers deliver quality assignments to the students.

Plagiarism Free Work

Get reliable and unique assignments by using our 100% plagiarism-free.

24 X 7 Live Help

Get connected 24*7 with our Live Chat support executives to receive instant solutions for your assignment.

Services For All Subjects

Get Help with all the subjects like: Programming, Accounting, Finance, Engineering, Law and Marketing.

Best Price Guarantee

Get premium service at a pocket-friendly rate at AssignmentHippo

FREE SAMPLE FILE

Client Review

I was struggling so hard to complete my marketing assignment on brand development when I decided to finally reach to the experts of this portal. They certainly deliver perfect consistency and the desired format. The content prepared by the experts of this platform was simply amazing. I definitely owe my grades to them.

Tap to Chat
Get instant assignment help