OS Project 0 February 25, 2015. Outline  Linux Installation  Linux Kernel Compilation  System Call Development  Kernel Modules / 452.

Slides:



Advertisements
Similar presentations
Drivers and the kernel1-1 Drivers and the kernel UNIX system has three layers: m The hardware m The operating system kernel m The user-level programs Kernel.
Advertisements

Computer System Laboratory
Linux Installation Chapter II. Linux Distributions Pre-packaged, installable Linux Anyone can compile a distribution, have to inculde GPL Available for.
Project 0: Linux & VM Dabbling CS-502, Fall Project 0: Linux & Virtual Machine Dabbling CS-502, Operating Systems.
Add a New System Call to Linux. Hw1 Add a New System Call to Linux and Compile Kernel Add a New System Call to Linux by Kernel Module.
Tutorial and Demos on Linux Virtual Machine
Post install; Live CD Chapter II / Part 1I. Post install After install completes, take out the install CD/DVD Reboot Check if boot loader is working properly.
Computer System Laboratory
WINDOWS 7 AND UBUNTU INSTALLING LINUX WITHIN WINDOWS.
Red Hat Installation. Installing Red Hat Linux is the process of copying operating system files from a CD, DVD, or USB flash drive to hard disk(s) on.
Linux Basics. What is an Operating System (OS)? An Operating System (OS) is an interface between hardware and user which is responsible for the management.
Using the “CLI” Unix / Linux Preparation Course May 25 Djibouti.
NCHU System & Network Lab Lab 3 System Call Operating System Lab.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
National Taiwan University OS Project 0 & 1 Advisor: Dr. Chih-Wen Hsueh Student: Tang-Hsun Tu 台灣大學 網媒所 / 資工所 Wireless Networking and Embedded Systems Laboratory.
LINUX System : Lecture 3 Vmware, Cygwin, LINUX installation Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
Kernel Development using Virtualization Installing VMWare and using a virtual machine to build and test a Linux Kernel.
For OS Experiments. What Do We Need? A Computer &
Nachos Project 1 Start-up and System call
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
Lab 11 Department of Computer Science and Information Engineering National Taiwan University Lab11 - Porting 2014/12/9/ 26 1.
Project 2. “Linux Fundamental” procfs By Dong Jae Shin.
Working with Ubuntu Linux Track 2 Workshop June 2010 Pago Pago, American Samoa.
Linux in a Virtual Environment Nagarajan Prabakar School of Computing and Information Sciences Florida International University.
1 Introduce Linux Speaker: Yi-Ji Jheng Date:
Introduction to Linux ( I ) Sidney Fong 4 th Feb 2006.
09/21/081 Ho Chi Minh city University of Technology Linux kernel R.M. Introduction of building Linux kernel from source.
1 What is a Kernel The kernel of any operating system is the core of all the system’s software. The only thing more fundamental than the kernel is the.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
COMPUTER SYSTEM LABORATORY Lab6 - Root Filesystem.
System Calls. The Linux we use is: Linux-Mandrake 7.0. In this project, you are going to change some kernel files and recompile the kernel. After you.
LOGO System Call. Introduction System call is the mechanism used by an application program to request service from the OS. Users use it to communicate.
Exercise #1: Exploring Open- Source Operating Systems with Virtual Machines J. H. Wang Sep. 25, 2015.
1 Copyright © 2015 Pexus LLC Patriot PS Personal Server Installing Patriot PS ISO Image on.
National Taiwan University OS Project 0 & 1 Advisor: Dr. Chih-Wen Hsueh Student: Tang-Hsun Tu 台灣大學 網媒所 / 資工所 Wireless Networking and Embedded Systems Laboratory.
LOGO Linux Installation. Linux Distribution Including shells, libraries, tools, compiler, servers, applications. Redhat, Fedora, Mandrake, SuSE, Debian,
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
COMP 3438 – Part I - Lecture 5 Character Device Drivers
Installing Applications in FreeBSD lctseng. Computer Center, CS, NCTU 2 Before we start  Permission issue root: the super user Like administrator in.
Lab 8 Department of Computer Science and Information Engineering National Taiwan University Lab8 - Root Filesystem 2015/11/10/ 22 1.
Implementation of Embedded OS
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 - OS Kernel 2014/10/21/ 16 1.
Embedded Software Design Week II Linux Intro Linux Kernel.
Spring 2007 Vmware and Linux kernel COMS W4118 Columbia University.
 CSC 215 : Procedural Programming with C C Compilers.
Rebuilding Linux Kernel Dedicated to penguin lovers everywhere 26 September 20161Rebuilding kernel by Visakh M R.
Add a New System Call to Linux
Operating System Kernel Compilation
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 20, 2016.
bitcurator-access-webtools Quick Start Guide
Outline Installing Gem5 SPEC2006 for Gem5 Configuring Gem5.
Implementation of Embedded OS
CSC227: Operating Systems
Computer System Laboratory
OS Homework 1 February 22, 2017.
Using Linux and Lab Setup OS Lab 1
linux and related thing
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 19, 2017.
Linux Programming Environment How to Run Linux in Windows
Hands-On Virtualization in the Classroom
Operating System Kernel Compilation
Exercise #1: Exploring Open-Source Operating Systems with Virtual Machines J. H. Wang Sep. 21, 2018.
Build A New Kernel and Add New System Calls in A Linux OS
COP 4343 Unix System Administration
bitcurator-access-webtools Quick Start Guide
Computer System Laboratory
Lab 1: Getting Started.
Operating System Kernel Compilation
Presentation transcript:

OS Project 0 February 25, 2015

Outline  Linux Installation  Linux Kernel Compilation  System Call Development  Kernel Modules / 452

Part I Linux Installation

Kernel versus Distribution / 454  Kernel is the core of the operating system including scheduler, memory management, file system, etc.  Distribution is a full functional environment including the kernel and a large collection of software applications.  The following slides are based on Ubuntu (desktop version).  Download Link:  desktop-amd64.iso (64-bit) desktop-amd64.iso  desktop-i386.iso (32-bit) desktop-i386.iso

Preparation (1/2) / 455  A computer  An Ubuntu DVD or image  A clear head and relaxed mind  Some drinks, food, or comics

Preparation (2/2) / 456  If you want to install Linux on your hard disk, please set at least 16GB unpartitioned space.  You may want to shrink your existing disk by disk management if there is no more unpartitioned space.  Ubuntu can coexist with Windows.  Change the boot sequence to boot from CD-ROM first.  If you want to install Linux on a virtual machine, you can use VirtualBox or VMware.  VirtualBox Website:  Please refer to this website for creating a VM in VirtualBox.website

/ 457

8

9

10

/ 4511

/ 4512

/ 4513

/ 4514

Some Useful Commands / 4515  Installing packages in Ubuntu  $ apt-cache search xxxx  $ sudo apt-get install xxxx  GNU Compiler Collection  $ gcc -o test test.c  $./test  Makefile  $ make  Text-mode editor  $ vim  SSH server and client  $ ssh -p port

Some Useful Tools / 4516  SSH server  $ sudo apt-get install ssh  SSH client for Windows  PieTTY 

References / 4517  鳥哥的私房菜   Ubuntu 正體中文站   Ubuntu Homepage 

Part II Linux Kernel Compilation

When Should We Compile Kernel? / 4519  There are various situations we have to compile the kernel.  Try new kernel patches for the latest laptops.  Enable/disable features built in the kernel.  Develop new features.  …  This slides are based on Linux 

Download Source Archives / 4520  Kernel Website: Mirror:

Preparation / 4521  Setting up build environment  $ sudo apt-get update  $ sudo apt-get install gcc vim ssh libncurses5- dev  Getting the source archive  $ cd ${HOME}  $ wget -3.X.X.tar.xz  Extracting the archive  $ tar Jxvf linux-3.X.X.tar.xz  $ cd linux-3.X.X

Kernel Configuration (1/2) / 4522  There are several ways to configure the kernel.  $ make config  $ make menuconfig  $ make xconfig  (It will need qt4-qmake and qt4-dev-tools packages.) ...  If you do not know how to configure, you can copy the old configuration file from /boot.  $ cp /boot/config-`uname -r`.config  $ make olddefconfig  $ make menuconfig  This step is optional.

Kernel Configuration (2/2) / 4523

Kernel Compilation / 4524  The first time (about 30min ~ 1.5hr):  $ make bzImage  $ make modules  (It takes quite a long time.)  $ sudo make modules_install  $ sudo make install  $ sudo mkinitramfs -o /boot/initrd.img-3.X.X 3.X.X  Do this whenever you reinstall the modules.  Configure the boot loader and then reboot!  Others (about 5~10min):  $ make bzImage  $ sudo make install  Then reboot!

Kernel Compilation with Multiple Cores / 4525  See how many cores on your machine.  $ cat /proc/cpuinfo | grep processor | wc -l  E.g., 4.  Compile with the number of jobs (threads).  $ make -j4 bzImage  $ make -j4 modules ...

Boot Loader Configuration (Optional) / 4526  Ubuntu will do this for you when installing the kernel.  Adding a new entry to /boot/grub/grub.cfg  If you got a black screen after booting the new kernel  Change ‘ gfxmode $linux_gfx_mode ’  ‘ gfxmode text ’

Rebooting / 4527  Do not forget to reboot every time you install a new kernel image!  You can use ‘ uname -a ’ to check current system information.

Part III System Call Development

Preparation / 4529  Find out whether the kernel is 32-bit or 64-bit version.  $ uname -p  32-bit: i386 i686  64-bit: x86_64

Adding a System Call (1/4) / 4530  Define your system calls.  Create a new file kernel/myservice.c.  Add this new attribute to kernel/Makefile.  obj-y += myservice.o #include asmlinkage int sys_myservice(int arg1) { printk(“My service is invoked!\n"); return arg1 * 10; }

Adding a System Call (2/4) / 4531  Declare the prototype of your system calls.  Add the declaration to include/linux/syscalls.h.  asmlinkage int sys_myservice(int arg1);

Adding a System Call (3/4) / 4532  Register a system call number (32-bit).  For Linux 3.X, it has a automatic way to generate system calls compared to the previous versions.  Add a new entry to arch/x86/syscalls/syscall_32.tbl.  350i386myservicesys_myservice  The generated file is in arch/x86/include/generated/uapi/asm, after compilation.

Adding a System Call (4/4) / 4533  Register a system call number (64-bit).  Add a new entry to arch/x86/syscalls/syscall_64.tbl.  313commonmyservicesys_myservice  The generated file is in arch/x86/include/generated/uapi/asm, after compilation.

System Call Invocation / 4534  Create a test file ap.c to try your system call.  Compile & execute.  $ gcc -o ap ap.c  $./ap 10 #include #define _GNU_SOURCE #include #define __NR_myservice 350 int main(int argc, char** argv) { printf("%d\n", syscall(__NR_myservice, atoi(argv[1]))); return 0; }

Related APIs / 4535  Access a block of data from/to user space in the kernel.  #include  unsigned long copy_from_user (void* to, const void __user* from, unsigned long n);  unsigned long copy_to_user (void __user* to, const void* from, unsigned long n);  Use the generic function syscall to invoke a specific system call in user space.  #include  int syscall(int number,...);  The first argument, number, is the system call number.

Some Useful Tools (1/2) / 4536  LXR Website:

Some Useful Tools (2/2) / 4537  Manpages  $ sudo apt-get install manpages-dev  $ man XXXX

References / 4538  Kernel Website   LXR 

Part IV Kernel Modules

An Example of Writing a Kernel Module (1/5) / 4540  Definition of the module structure

An Example of Writing a Kernel Module (2/5) / 4541  Initialization and cleanup functions

An Example of Writing a Kernel Module (3/5) / 4542  File operations

An Example of Writing a Kernel Module (4/5) / 4543  User AP

An Example of Writing a Kernel Module (5/5) / 4544  Makefile  Testing  $ sudo insmod hello.ko  $ dmesg  $ sudo./ap  $ dmesg  $ sudo rmmod hello

Q & A / 4545