GithubHelp home page GithubHelp logo

kernel's Introduction

team work with Shokoofa Ghods

steps

  • write systemcall
  • add it to target files
  • compile kernel

position of operating system

the lowest level is hardware which consists of physical devices such as ICs, cathode lamps and .. on top level we've got Michroarchitecture in which physical devices interact with eachother. Normally this levele has CPU registers and a Data Path of ALU.

a computer system hierarchy
  • applications
  • system programs (compilers, editors, shell, command iterpreter)
  • operating system
  • machine language
  • michroarchitecture
  • physical devices
shell
  • is the interface between end user and kernel and its duty is to interprete user commands to into understandable system calls for kernel.
  • in old operating systems like MS-DOS shell was about text commands. Howerever, today there are both text and graphical shells
  • shell is located at User space, in contrary kernel is located at kernel space
systemcall
  • as defined it's a method to get services from the kernel
  • the picture below simply shows how a system call works:
steps for adding the systemcall and compiling the kernel
  • update os
sudo apt update
  • get the latest version of linux kernel from kernel.org
  • check the current kernel version
uname -r
  • change directory to new kernel and create a directory for systemcall
cd linux-version
mkdir mysyscall
cd mysyscall
  • make a c program for the systemcall
vim mysyscall.c
#include <linux/kernel.h>
#include <linux/syscalls.h>

SYSCALL_DEFINE0(mysyscall)

{
    printk("This is my attempt for a basic syscall.\n");
    return 0;
}
  • create Makefile and add the proper code
touch Makefile
echo obj-y : mysyscall.o > Makefile
  • return back to the kernel dir and add the new syscall to the line containing core-y
cd ..
vim Makefile
kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ mysyscall
  • enter the header file add the follwing command
vim include/linux/syscalls.h
asmlinkage long sys_mysyscall(void);
  • add your syscall function tp system call table
vim arch/x86/entry/syscalls/syscall_64.tbl
linenum 64 mysyscall sys_mysyscall
  • specify number of cores for the process of compile, in this case I allocate 2 cores on my vm
make -j2
  • start the process which may take some time according to system resources
make install -j2

kernel's People

Contributors

v-nafiseh 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.