Drivers and the Kernel. Computer Center, CS, NCTU 2 Introduction – UNIX Kernel and Shell interpret.

Slides:



Advertisements
Similar presentations
Operating-System Structures
Advertisements

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.
Operating System Structures
1 OS Structure, Processes & Process Management. 2 Recap OS functions  Coordinator  Protection  Communication  Resource management  Service provider.
3.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 3: Operating-System Structures System Components Operating System.
Chapter 2: Operating-System Structures
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Figure 1.1 Interaction between applications and the operating system.
Common System Components
Os31 Chapter 3 Operating-System Structures. os32 Outlines System Components Operating System Services System Calls System Programs System Structure Virtual.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Chapter 12 Drivers and the Kernel. Computer Center, CS, NCTU 2 Roles of Kernel  Components of a UNIX System User-level programs Kernel Hardware  Two.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 Operating System Organization.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Abhinav Kamra Computer Science, Columbia University 3.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 3: Operating-System Structures.
 Introduction Introduction  Definition of Operating System Definition of Operating System  Abstract View of OperatingSystem Abstract View of OperatingSystem.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
System Administration HW1 huanghs. Computer Center, CS, NCTU 2 Requirements  Basic Install FreeBSD and upgrade to up-to-date –RELEASE Recompile your.
Drivers and the Kernel. Computer Center, CS, NCTU 2 Roles of Kernel  Components of a UNIX System User-level programs Kernel Hardware  Two roles of kernel.
The Linux /proc Filesystem CSE8343 – Fall 2001 Group A1 – Alex MacFarlane, Garrick Williamson, Brad Crabtree.
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.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
Silberschatz and Galvin  Operating System Concepts Module 3: Operating-System Structures System Components Operating System Services System Calls.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3.
OPERATING SYSTEMS Lecture 3: we will explore the role of the operating system in a computer Networks and Communication Department 1.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
3.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 3: Operating-System Structures System Components Operating System.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
3.1 Operating System Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual.
Processes Introduction to Operating Systems: Module 3.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
CS 346 – Chapter 2 OS services –OS user interface –System calls –System programs How to make an OS –Implementation –Structure –Virtual machines Commitment.
1 CSE Department MAITSandeep Tayal Operating-System Structures System Components Operating System Services System Calls System Programs System Structure.
Drivers and the Kernel. Computer Center, CS, NCTU 2 Roles of the Kernel – (1)  Components of a UNIX System User-level programs Kernel Hardware  Kernel.
Silberschatz, Galvin and Gagne  Operating System Concepts UNIT II Operating System Services.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 3 Operating-System Structures Slide 1 Chapter 3 Operating-System Structures.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
CSC414 “Introduction to UNIX/ Linux” Lecture 2. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Linux Kernel Programming (LKP). LKP New sub-course New sub-course We will learn together We will learn together Evaluation of this part of course will.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Operating System Structure Lecture: - Operating System Concepts Lecturer: - Pooja Sharma Computer Science Department, Punjabi University, Patiala.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
1.3 Operating system services An operating system provide services to programs and to the users of the program. It provides an environment for the execution.
 Components of a UNIX System › User-level programs › Kernel › Hardware  Two roles of kernel › High-level abstractions  Process managements  File system.
Introduction to Operating Systems Concepts
Computer System Structures
Module 3: Operating-System Structures
Kernel Design & Implementation
Drivers and the Kernel lctseng arr. by pschiu.
Chapter 4 – Introduction to Operating System Concepts
Operating System Structure
Drivers and the kernel UNIX system has three layers: Kernel
Chapter 2: Operating-System Structures
Chapter 2: System Structures
Chapter 3: Operating-System Structures
Drivers and the Kernel.
Chapter 2: Operating-System Structures
Operating Systems Lecture 3.
Introduction to Operating Systems
Drivers and the Kernel.
CS533 Concepts of Operating Systems Class 13
Bhyve frank.
Chapter 2: Operating-System Structures
Operating System Concepts
Operating System Concepts
Presentation transcript:

Drivers and the Kernel

Computer Center, CS, NCTU 2 Introduction – UNIX Kernel and Shell interpret

Computer Center, CS, NCTU 3 Roles of Kernel  Components of a UNIX System User-level programs Kernel Hardware  Two roles of kernel (OS) High-level abstractions  Process managements –Time sharing, memory protect  File system management  Memory management  I/O management Low-level interface  drivers

Computer Center, CS, NCTU 4 Kernel Types Since BSD…

Computer Center, CS, NCTU 5 Kernel Types  Two extreme types Micro kernel  Provide only necessarily, compact and small functionalities  Other functions is added via well-defined interface Monolithic kernel ( 龐大的 kernel – e.g. unix)  Whole functionalities in one kernel  Modern OS Solaris  Completely modular kernel  Load necessarily module when it is needed BSD/Linux-derived system  Much of the kernel's functionality is contained in modules Concept of being modulized… only provides essential functionalities; Put other sophisticated functions into user level e.g. I/O management in the user level More integrated… increase scalability and less difficult in maintenance How to communicate?  Message passing – less efficient Monolithic kernel developing towards micro kernel (being more modulized), but without IPC (message passing) problem “Load only when you need.”

Computer Center, CS, NCTU 6 Kernel related directory  Build directory and location SystemBuild DirectoryKernel file FreeBSD/usr/src/sys /kernel ( < 4.x) /boot/kernel/kernel (> 5.x) Red Hat/usr/src/linux /vmlinuz or /boot/vmlinuz Solaris-/kernel/unix SunOS/usr/kvm/sys/vmunix *.ko(s)

Computer Center, CS, NCTU 7 Why configure the kernel?  The native kernel is often big and common  Tailoring kernel to match site situation Purge unnecessary kernel devices and options Add functionalities that you want  OS patch Remedy security hole of kernel implementation  Fine-tune system performance Such as adjusting important system parameters  Adding device drivers  Fast boot time  Lower memory usage Generic: with various devices…, functions supported kernel image  memory usage

Computer Center, CS, NCTU 8 Building a FreeBSD Kernel  Kernel source /usr/src/sys  Kernel configuration file /usr/src/sys/ /conf  GENERIC, LINT (< 4.X)  GENERIC, “ make LINT ” under this dir ( > 5.x)  Steps to build a new kernel Edit /usr/src/sys/ /conf/ % cd /usr/src ; % make buildkernel KERNCONF=SABSD % make installkernel KERNCONF=SABSD  To generate LINT file represents one of i386, amd64, ia64, powerpc, sparc64 SABSD: configuration file LINT file: lists all options

Computer Center, CS, NCTU 9 To Build a FreeBSD Kernel…  What to Choose?  What to Load?  Option Settings?  Device Drivers?

Computer Center, CS, NCTU 10 Finding the system hardware  Before venturing into kernel configuration Get an inventory of the machine’s hardware Microsoft's Device Manager  dmesg cat /var/run/dmesg.log  pciconf man -k Atheros psm0: irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: [ITHREAD] psm0: model Generic PS/2 mouse, device ID 0 class=0x card=0x058a1014 chip=0x c vendor = 'Atheros Communications Inc.' device = 'AR5212 Atheros AR abg wireless' class = network subclass = ethernet Listing devices from M$ windows Listing devices from dmesg If not originally support by GENERIC… Ans: Use pciconf –l to list all attached devices Than man –k [company name] to lookup usage

Computer Center, CS, NCTU 11 Building a FreeBSD Kernel – Configuration file  Each line is a control phrase [Ref] Keyword + arguments KeywordFunctionExample machineSets the machine typei386 or amd64 cpuSets the CPU type I586_CPU or HAMMER identSets the name of the kernelSABSD maxusers Sets the kernel ’ s table sizes 0 optionsSets various comiple-time optionsINET or INET6 deviceDeclares devicesfxp The explanations on options and devices… e.g. device = fxp

Computer Center, CS, NCTU 12 Kernel backup  Kernel file locations Put in the /boot directory /boot/GENERIC/kernel, /boot/kernel.old/kernel /kernel.GENERIC, /kernel.old (Freebsd 4.x)  If something goes wrong ok mode !  unload kernel; load kernel.old/kernel  load kernel modules mv /boot/kernel /boot/kernel.bad Your last chance to prevent module missing…to survive!! Old kernel is automatically moved to kernel.old when you’re making the new kernel Or just simply cp your GENERIC /boot/kernel first!

Computer Center, CS, NCTU 13 Ok mode Or “enable modules” in the ok mode..

Computer Center, CS, NCTU 14 Tuning the FreeBSD Kernel  sysctl command Dynamically set or get kernel parameters All changes made by sysctl will be lost across reboot Use sysctl to tune the kernel and test it, then recompile the kernel Format: % sysctl [options] name[=value] … Ex: % sysctl –a list all kernel variables % sysctl –d kern.maxfilesprint the description of the variable % sysctl kern.maxfilesprint the value of the variable % sudo sysctl kern.maxfiles=2048 e.g. maxusers/maxfiles and providing www service… The other way is to write your settings into /etc/sysctl.conf…

Computer Center, CS, NCTU 15 Kernel modules  Kernel module location /boot/kernel/*.ko /modules ( Freebsd 4.x)  kldstat  Load/unload kernel modules kldload(8), kldunload(8) zfs[/boot/kernel] -chiahung- kldstat Id Refs Address Size Name xc abd60 kernel 2 1 0xc08ac000 13b0fc zfs.ko 3 2 0xc09e8000 3d5c opensolaris.ko 4 2 0xc09ec000 16b84 krpc.ko 5 1 0xc0a c48 if_le.ko Module loading… e.g. kldload if=fxp  Where details can be viewed

Computer Center, CS, NCTU 16 E.g. Procedure of Loading a Device Module  Loading a device module 1.pciconf –l for a device 2.man vendor name for module name in BSD 3.grep the name in /boot/kernel/*.ko 4.kldload [module name] 5.Setup permanently by recompile the kernel, or add [module name]_enable=“YES” in /boot/loader.conf

Computer Center, CS, NCTU 17 Reference  g-config.html g-config.html  /usr/src/sys/ /conf NOTES LINT GENERIC  machine dependent kernel configuration notes.