Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In an operating system, what is the difference between a system call and an interrupt?

Tags:

In an operating system, what is the difference between a system call and an interrupt? Are all system calls interrupts? Are all interrupts system calls?

like image 763
Brad Penney Avatar asked Nov 11 '15 16:11

Brad Penney


People also ask

What is the difference between system call and system program in operating system?

The system calls are list of the function that will be call in section between user and kernel . But the system program is the program that can do system works like : Change system settings .

What is the difference between a system call and a function call?

The main difference between system call and function call is that a system call is a request for the kernel to access a resource while a function call is a request made by a program to perform a specific task.

What are the difference between software interrupt & A subroutine call?

A subroutine is called by a program instruction to perform a function needed by the calling program. While Interrupt is initiated by an event such as an input operation or a hardware error.


1 Answers

Short Answer: They are different things.

  • A system call is call by software running on the OS to services provided by the OS.
  • An interrupt is usually external hardware component notifying the CPU/Microprocessor about an event that needs handling in software (usually a driver).

I say usually external, because some interrupts can be raised by software (soft interrupt)

Are all system calls interrupts? Depends

Are all interrupts system calls? No

Long answer: The OS manages CPU time and other hardware connected to the CPU (Memory (RAM), HDD, keyboard, to name a few). It exposes services that allow user programs to access the underlying hardware and these are system calls. Usually these deal with allocating memory, reading/writing files, printing a document and so on.

When the OS interacts with other hardware it usually does so through a driver layer which sets-up the task for the hardware to perform and interrupt once the job is done, so the printer may interrupt once the document is printed or it runs out of pages. It is therefore often the case that a system call leads to generation of interrupts.

Are all system calls interrupts - Depends as they may be implemented as soft interrupts. So when a user program makes a system call, it causes a soft interrupt that results in the OS suspending the calling process, and handle the request itself, then resume the process. But, and I quote from Wikipedia,

"For many RISC processors this (interrupt) is the only technique provided, but CISC architectures such as x86 support additional techniques. One example is SYSCALL/SYSRET, SYSENTER/SYSEXIT (the two mechanisms were independently created by AMD and Intel, respectively, but in essence do the same thing). These are "fast" control transfer instructions that are designed to quickly transfer control to the OS for a system call without the overhead of an interrupt"

like image 173
Ali Avatar answered Nov 08 '22 07:11

Ali