answersLogoWhite

0

How is system call executed?

Updated: 10/3/2023
User Avatar

Wiki User

10y ago

Best Answer

For a user most system calls are simply wrapped in simple command utilities such as chroot and mkdir and the like.

But system calls proper are made by software, plain and simple. Usually how it works on the low level is dependent on the architecture being used. For "simplicity" I'll refer to x86(_64).

When a system call is made, it's done by putting the parameters of the call in a series of general purpose registers in the CPU, then either signaling an interrupt or, in the case of 64-bit x86, actually using the syscall instruction.

What happens then is a context switch occurs, and the CPU is switched over to kernel mode and the kernel itself is actually running now and has your system call. Meanwhile, the process that made the system call is put in the "blocked" list until the needs of the system call are met.

Remember that a system call is a simple request for a service from the operating system by something in user space. Things in user space can't do a whole lot themselves in reality, and have to ask the operating system for a lot of support.

While an application can do a lot with the CPU, as soon as it needs any sort of hardware support, or more memory, or less memory, it has to ask the operating system for it. For example:

I wrote a text document in vi. To save, vi has to make a system call (Actually, a LOT of system calls.) to the kernel to actually write the buffer to disk.

Think of system calls as being among the building blocks of the actual execution of software on *nix systems. The process will happily use CPU instructions without operating system help, but applications make constant use of hardware in some way, and to do that, they have to use instructions for the kernel, who may or may not actually GRANT the requests based on permissions or sanity of the system call, as opposed to a CPU which will MOSTLY do whatever it is told even in user mode.

The only time a CPU will actually reject an instruction is if its bonkers. Either it's an opcode that makes no sense to the CPU or, more commonly, it is an opcode that requests memory be used in some way that is flat out disallowed in virtual memory. In those cases the CPU will usually fire off an exception and force a context switch to the kernel to handle the error. It'll be up to the operating system how to proceed, but usually, except in cases of page faults, this means death to the offending process. The cases where the CPU will reject an instruction because it's plain invalid or violates memory access rules is called a "fault."

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How is system call executed?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which system call can be used to receive the identifier of the currently executed process?

getpid(2)


What system calls have to executed by a command interpreter or shell in order to start a new process?

The fork system call is used to create new child process which followed his parent process


What do you call a person who is getting executed?

condemned


Where is the fuction call of main function?

The main function is the entry point into a program. When the Operating System launches the program the main function gets executed.


Which of the following statement is executed after call moduleB?

the first statement in ModuleB


What system calls have to be executed by a command interpreter or shell in order to start a new process?

In Unix systems, a fork system call followed by an exec systemcall need to be performed to start a new process. The fork call clones thecurrently executing process, while the exec call overlays a new processbased on a different executable over the calling process.


How does juvenile justice system work in Iran?

juvenile offenders are sometimes executed


Can bash be executed on a Linux system?

Yes. In fact, it is often the default shell.


What is a job pool in operating system?

Is a set of job that is executed acording a needs.


What is the system for assistant call from the S.A.R organization?

A System call is a mechanism used by an application for requesting a service. What is system calls? In computing, a system call ...


What are the Call of Duty 2 system requirements?

call of duty system requirements


How system call are related with the file system?

The system call is related to the file system because of the program that initializes the access to a file.