in Operating System
209 views
2 votes
2 votes

System calls are usually invoked by using

  1. a software interrupt
  2. polling
  3. an indirect jump
  4. a privileged instruction
in Operating System
by
209 views

2 Answers

1 vote
1 vote
Answer is - a) a software interrupt

4 Comments

why not privileged instruction,Software interrupt handled at user level program.
1
1
Whenever an interrupt occurs control is transferred to kernel where the corresponding service routine is called using  priviliged mode . We cannot call priviliged instruction directly from user program without going to kernel
3
3
why only software interrupt, why not hardware interrupt ??
0
0
actually we can go to the superuser mode, and then execute system calls manually like function calls which are done via privilaged instructions.

Answer should be D
0
0
1 vote
1 vote

The answer is A.

Let's see why. I'll explain with some background information.

 

There's two types of code — the user defined code (programming, basically) and OS code. To ensure proper functioning, these two codes should always be executed separately, and never together. For that, we need to distinguish between the user-defined code and the OS code.

To do so, a bit called mode bit is used in the hardware, that tells you the current mode of the machine. 0 => kernel mode and 1=> user mode. Hence, this mode bit helps us distinguish whether the user code, or the OS code is running.

A flag is a single bit variable that indicates something. Example: carry flag, overflow flag, zero flag etc. Mode bit can also be called as mode flag.

 

Now, when a user process needs some OS service(s), it asks the OS via a system call. It is clear that "system call" is nothing but the process calling the system for assistance.

When a system call is made, the mode bit changes to 0, and the machine enters the kernel mode (because system services are OS code, and to execute it we need to be in kernel mode).

 

A system call is just one of the ways to enter the kernel mode. The other two ways are — interrupts and traps.

 

Kernel mode can run both privileged and non-privileged instructions, while the user mode can run only non-privileged instructions.

Since, while making a system call, we're in the user mode, we can't make any privileged instruction. So Option D is incorrect. Options B and C are just fillers.

 

Is Option A correct? Yes. Why?

As said above, kernel mode is entered only via

  • system calls
  • interrupts
  • traps

These three words have somewhat overlapping definitions sometimes. A trap is usually a software interrupt, and an interrupt is an umbrella term for both Hardware and Software interrups.

Anyway, a system call is a process calling the OS => software calling the OS. Could be a trap, could be a software interrupt, Trap isn't in the options and the word "usually" is said in the question, so Option A is the option to go with.



 

More info

  • When going from user mode to kernel mode; the instruction is non-privileged because generating privileged instruction in user mode isn't possible.
  • When going from kernel mode to user mode; the instruction to switch to the user mode is privileged.
Answer:

Related questions