Tuesday, 10 April 2018

Adding a system call in XV6 OS

Adding a system call in XV6 OS

In this blog, I will show you how to add a system call to XV6 OS. We will just add a simple HelloWorld system call which will print hello world and the argument passed to the system call.

Steps:

For adding the system call we need to make changes in the following files:
  1. syscall.c
  2. syscall.h
  3. user.h
  4. usys.S
  5. sysproc.c


First, we add the call to the list in syscall.c





Next, assign it a number in syscall.h




give it a prototype in user.h:




Add it to usys.S, which generates the user-space assembly code for it





Finally, we add the implementation somewhere (e.g. sysproc.c)



Testing

To test if the system call works, create a c file and use the system call in it. Remember to add the c file in Makefile so that you can use it.




Adding it to make file


No comments:

Post a Comment