Xv6 Operating System - Adding a New System Call
Today, we are going to learn about a new Operating System(OS). This new Operating System name is Xv6. X stands for Operating System(OS) name. v6 stands for version 6. There are also a few concepts about System Call, User Program, etc. The concepts are like adding a user program and also adding a system call.
Before, learning about all these concepts we need to know basics of one thing. It is we need to know about the Xv6 Operating System basics, history, language in which it is written and etc. So, let us now know about the Xv6 Operating System(OS).
Xv6 Operating System
Xv6 Operating System is not a new Operating System. It is just an re - implementation of Sixth Edition Unix in ANSI(American National Standards Institute) C style for multiprocessor Intel x86 and RISC - V systems.
This Operating System was developed by Massachusetts Institute of Technology also known as MIT. This Operating System was written in C language with the help of Assembly Language too. This Operating System belongs to the family of Unix. The type of kernel is Monolithic. The User Interface used in Command Line Interface(CLI). To use this Operating System we need to have a license known as MIT(Massachusetts Institute of Technology) License.
Xv6 Operating System was invented for the method of practice of teaching, especially as an academic subject or any theoretical concept. This method of practice can be called as pedagogy.
This Operating System is created as a replacement for v6 source code. This is not a heavy weight Operating System i.e. light weight Operating System. Here, the time to compile the code is very low and it also allows remote debugging.
Adding a System Call to Xv6 Operating System
Programs can communicate with the operating system by making a system call. When a computer application requests anything from the kernel of an operating system, it performs a system call. Hardware services, process creation or execution, and communication with kernel services, such as application and process scheduling, all use system calls.
Creating a System Call to Xv6 Operating System
You may begin by navigating to the syscall.h file, where each system call in the Xv6 system has been given a number. As you can see, this file already defines 21 system calls. Let's go and add the next line to your system call reserver's reservation number.
The next step is to add a system call reference to the syscall.c file. This file provides an array of function pointers that use the indices mentioned above to point to system calls that are specified elsewhere. Add the next line to this file to add your own custom system call.
This indicates that the sys getyear function will be run when the system call with system call number 22 occurs. Consequently, you must implement this function. But you won't use this file to put it into practice. Simply insert the function prototype into this file.
Therefore, add the following line in the appropriate location within this file. You can see that the definitions of the other 21 system call functions are similar.
The following function prototype has to be added to the syscall.c file.
To implement the system call, we need to open sysproc. C file. We need to open this file because system call functions are defined here.
The year which the get year is 1975
This is how the the user program from Xv6 Operating System is extracted and we need to follow the steps to make this possible.
This is how the system call is added to the Xv6 Operating System.ng-system/images/xv6-operating-system-adding-a-new-system-call.png" alt="Xv6 Operating System - Adding a New System Call"/>