System Call and Function Call

Completed : 10.06.2018 Created by: AYDIN ÇALIKOĞLU

Preview
System Call and Function Call

A typical processor executes instructions one by one. But there may be occasions where the processor has to stop current instruction and execute some other program or code segment (residing in some other place). After doing this the processor returns to normal execution and continues from where it left off. A system call and a function call are such occasions. A system call is a call to a subroutine built in to the system. A function call is a call to a subroutine within the program itself.

What is a System Call?

System calls provide programs running on the computer an interface to talk with the operating system. When a program needs to ask for a service (for which it does not have permission to do that by itself) from the kernel of the operating system, it uses a system call. User level processes do not have the same permissions as the processes directly interacting with the operating system. For example, to communicate with and external I/O device or to interact with any other processes, a program uses system calls.

What is a Function Call?

A function call is also called a subroutine call. A subroutine (also known as a procedure, function, method or routine) is part of a larger program that is responsible for carrying out a specific task. The larger program may execute a heavy workload, and the subroutine may be performing just a simple task, which is also independent of the remaining program coding. A function is coded in such a way that it may be called multiple times and from different places (even from within other functions). When a function is called, the processor may go to where the code for the function is residing and execute the instructions of the function one by one. After completing the functions, the processor will return to exactly where it left off and continue the execution starting from the next instruction. Functions are a great tool for code reuse. Many modern programming languages support functions. A collection of functions is called a library. Libraries are often used as means of sharing and trading software. In some cases, the whole program could be a sequence of subroutines (e.g. threaded code compilation).


Tüm Yorumlar - All Contents