Code Monkey home page Code Monkey logo

samyukthagopalsamy / top_command_in_xv6_operatingsystem Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 674 KB

Using system calls to implement the top command in the XV6 Operating System. 'top' is a basic Unix command which provides a dynamic real-time view of the running system.

License: Other

Makefile 2.25% C++ 5.74% C 79.10% Assembly 4.45% Perl 2.72% Objective-C 1.88% Shell 2.35% Ruby 0.46% OpenEdge ABL 1.06%
top xv6-extensions xv6-os system-call

top_command_in_xv6_operatingsystem's Introduction

Using system calls to implement the top command in the XV6 Operating System XV6 is a simple Unix-like teaching operating system, developed by MIT.
It is an implementation of the Unix version 6 using ANSI C language for x86 platforms.
top is a basic Unix command which provides a dynamic real-time view of the running system. The goal of this project is to include the top command in the XV6 environment, similar to that of the one in Linux. This is done by developing a user program which includes system calls to display the list of processes, users of the system resources and the summary information of the system.
The user program included in xv6 displays the Pid, process name, the status of the processes, parent id, and memory size.

Follow
The xv6 operating system is run on a QEMU virtual machine on top of a 64-bit Ubuntu 18.04.1 LTS machine.
The following tools and packages are to be installed on the Ubuntu Linux system:

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install multi-lib
sudo apt-get install qemu
sudo apt-get install git

In case of a 64-bit OS, there is a chance that the Makefile will not be able to find qemu. In that case, you should edit the Makefile at line 54 and add the following code:
QEMU = qemu-system-x86_64

Install xv6 by creating a directory, and clone xv6 to that directory:
$ git clone git://github.com/mit-pdos/xv6-public.git

Compile xv6:
$make

Compile and run the Qemu emulator:
$make qemu

This will start up a window with QEMU emulator and will start the shell prompt of the xv6 operating system.

System call used:

New system call named sys_top() and sys_date() are included in xv6. To add a system call that can be called in xv6's shell, some changes in the following files have to be made:
• sysproc.c - the real implementation of the method is added here
• syscall.h - the position of the system call vector that connects to the implementation is defined here
• user.h - the function that can be called through the shell is added here
• usys.S - use the macro to define connect the call of the user to the system call function

  1. The system call sys_top( ) is included in the file proc.c
  2. #define sys_top 24 is included in the file syscall.h
  3. The function void top (void) is added under the system calls in the file user.h
  4. The function syscall(top) is added in the file usys.S

Since the permission for accessing the p table was denied, the sys_top() system call is included in the file proc.c instead of the file sysproc.c
The included system call sys_top( ) iterates the p-table and gets the pid, process name, status of the processes and the memory size.
By using the system call sys_top( ) the following system information are successfully displayed:
• Current time, number of users.
• Total number of tasks running.
• Memory statistics – total physical memory present, free and used.
• PID and the corresponding Process name
• Memory size (KiB)
• %MEM and Total memory used by the processes
• State of the processes (running, sleeping, zombie, runnable, unused)

The system information listed above is obtained as follows:

  1. The current system time is obtained using the date system call included in Xv6.
  2. RES is obtained from proc of individual process.
  3. %MEM is obtained by the formula: %mem = (RES / total memory) * 100%. The total physical memory in xv6 is constant which is 0xE000000 (224 MB)
  4. STATE and PID of processes are obtained from proc of current processes which are present in the ptable . ptable can hold a maximum of 64 processes as defined .
    dd

top_command_in_xv6_operatingsystem's People

Contributors

samyukthagopalsamy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.