edited by
12,141 views
12 votes
12 votes

Which one or more of the following options guarantee that a computer system will transition from user mode to kernel mode?

  1. Function Call
  2. malloc Call
  3. Page Fault
  4. System Call
edited by

4 Answers

11 votes
11 votes
  1. function call: functions may be user defined so It also does not guarantee to switch from user to kernel mode.
  1. Malloc () call: It can be done in both user and kernel modes. Hence, It cannot guarantee switching.
  1. Page fault : When a page fault occurs, required page must be loaded from secondary to main memory. It will be done in privileged mode and guarantee user mode to kernel mode switching.
  1. System call : System calls are executed  in kernel mode only. It definitely guarantee switching.

Hence Ans is C,D.

6 votes
6 votes
System Call guarantees that a computer system will transition from user mode to kernel mode.

System calls are the mechanism by which user-level programs can request services from the operating system (OS) and transition from user mode to kernel mode. When a user-level program executes a system call, it causes an interrupt to occur, which transfers control to the OS kernel. The OS kernel then performs the requested service and returns control to the user-level program.

Function calls and malloc calls do not necessarily result in a transition to kernel mode. They are both operations that can be performed entirely within user mode.

A page fault can trigger a transition to kernel mode, but it is not guaranteed to do so. A page fault occurs when a program attempts to access a page of memory that is not currently in physical memory. In this case, the OS must handle the page fault and may need to allocate physical memory or swap pages in/out of memory. This requires kernel mode access, but some page faults can be handled entirely within user mode without kernel intervention.
4 votes
4 votes

Options A, C, and D should be straightforward. (Comment if you have any doubts)

For option B, a good read is available here https://stackoverflow.com/a/5716525

The point 1 in above link is important here,

malloc() will search its managed pieces of memory to see if there's a piece of unused memory that satisfy the allocation requirements.

It implies that a system call is not required (therefore no switch to kernel mode) to satisfy the requirement.

Hence, answer is C, D.

0 votes
0 votes
Kernal is the core of operating system,though which we access key functionalities of operating system(system calls).

Switch of mode(from user to kernal) is required when program wants to execute instructions that are not in user space,hence wants to access privileged memory.

A. Function call access only the user space => Not required to switch modes. => Not required to switch to kernal modes.

B. Malloc search for unallocated memory from its heap from Logical address space of process. => Not required to switch to kernal modes. {https://stackoverflow.com/a/5716525}

C. On page faults we will call pageFaultServiceRoutine which is a system call. => Required to switch to kernal modes.

D. All system calls/interrupts are only executed in kernal mode. => Required to switch to kernal modes.

ANS: C,D
Answer:

Related questions

10.3k
views
1 answers
8 votes
admin asked Feb 15, 2023
10,281 views
Which one or more of the following need to be saved on a context switch from one thread $\text{(T1)}$ of a process to another thread $\text{(T2)}$ of the same process?Pag...
15.3k
views
5 answers
21 votes
admin asked Feb 15, 2023
15,263 views
Which one or more of the following $\text{CPU}$ scheduling algorithms can potentially cause starvation?First-in First-OutRound RobinPriority SchedulingShortest Job First
8.5k
views
3 answers
4 votes
admin asked Feb 15, 2023
8,548 views
Which of the following statements is/are $\text{CORRECT}?$The intersection of two regular languages is regular.The intersection of two context-free languages is context-f...