The interrupt can be called by the int operator in the assembler, and the code in the cell with the specified number will be transferred from the interrupt table. In linux, it is possible to call an intx80 interrupt, called syscall. From the programmer’s side, this will look like a call to a library function, which, nevertheless, will be processed in kernel space. So what is the difference between a system call and a software interrupt if the first one is also called via intx80?

  • 3
    No difference. From the point of view of the processor, both are interruptions (as you called it software). A separate name just to immediately understand that a call to a kernel function is taking place. - Mike
  • one
    On the other hand, there are no other interruptions for the working OS from the point of view of the user code. There is nothing more to call. In addition, on some processors of the software interrupt system and a separate instruction such an int may not be present, and there the syscall will be implemented differently. And on other processors, a specialized "kernel call" instruction generally serves to call the kernel. However, it will continue to be called a system call, which would emphasize that this is not an ordinary library call - Mike
  • @Mike you say the floor of the working OS; no other interruptions exist, however, nothing prevents us from writing and assembling the assembler code that conditionally calls int21. And it will launch such a program, and it will work itself out for itself, just the control will be transferred to the code from the interrupt table. By the way, do I understand correctly that in this table a link to any user code can be placed? - aryndin 7:37 pm
  • one
    Yes, you can call int 21h, on this your program will crash due to the fact that the linux kernel does not provide any interrupts except 80h. All modern operating systems run in protected processor mode. The kernel does not allow user programs to read or write anything in the interrupt table. Accordingly, the user code will not be able to place a link to any code anywhere (unless of course you specifically do not write your own system call in the kernel to do this). During real-time OS (DOS) programs used their interrupt handlers - Mike

1 answer 1

In fact, these are different, incomparable things. By Wikipedia definitions:

  • System call - the application program calls the operating system kernel to perform any operation.
  • An interrupt is a signal from software or hardware that informs the processor of the occurrence of an event requiring immediate attention.
  • Software interrupts (in Russian terminology) are interruptions that are initiated by the execution of a special instruction in the program code.

Those. A system call is an abstraction of an OS in which there is a separation between user space and kernel space, and a software interrupt is a mechanism for the interaction of program code with a processor.

Indeed, system calls are often implemented using software interrupts , but this is not necessarily the case, for example, on amd64, at least 3 methods are supported:

  • The syscall instruction is the main method, it appeared only on the amd64 architecture, in the x86 compatibility mode there is not on all processors (only on amd processors), the fastest of the listed ones.
  • The sysenter instruction is similar to the old instruction, appeared at the time of Pentium 2, the main method when building for i686 architecture.
  • int 80h is considered an outdated ( legacy ) way, relatively slow, the time for context switching is about twice as long as using syscall .