* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Ch1 Introduction to the Linux Kernel
Survey
Document related concepts
Library (computing) wikipedia , lookup
Burroughs MCP wikipedia , lookup
Mobile operating system wikipedia , lookup
Copland (operating system) wikipedia , lookup
Distributed operating system wikipedia , lookup
Plan 9 from Bell Labs wikipedia , lookup
Linux adoption wikipedia , lookup
Berkeley Software Distribution wikipedia , lookup
Caldera OpenLinux wikipedia , lookup
Unix security wikipedia , lookup
Linux kernel wikipedia , lookup
Spring (operating system) wikipedia , lookup
Process management (computing) wikipedia , lookup
Transcript
作業系統 Operating Systems 課本:Linux Kernel Development, 3rd Ed., by R. Love, Sams Publishing. (全華圖書代理) 上課時間:星期二下午5 (204),星期三下午5, 6 (204) 評量方式 :實習 20% 作業 20% 期中考 30% 期末考 30% 課程網頁:http://ares.ee.nchu.edu.tw/Course.files/os103/ 大綱 Kernel Introduction Process Management System Calls Interrupt Handlers Timers Memory Management Virtual Filesystems I/O Layers The Process Address Space Ch1. Introduction to the Linux Kernel Introduction to Linux (1) Linux was developed by Linus Torvalds in 1991 as an operating system for computers using the Intel 80386 microprocessor Linux is a full-fledged operating system running on At the time was a new and advanced processor AMD x86-64, ARM, Compaq Alpha, CRIS, DEC VAX, H8/300, Hitachi SuperH, HP PA-RISC, IBM S/390, Intel IA-64, MIPS, Motorola 68000, PowerPC, SPARC, UltraSPARC, and v850 It runs on systems as small as a watch to machines as large as room-filling super-computer clusters. Introduction to Linux (2) Linux is a Unix clone Linux borrows many ideas from Unix and implements the Unix API It is not a direct descendant of the Unix source code like other Unix systems The basics of a Linux system are It is not Unix The kernel, C library, compiler, tool chain, and basic system utilities, such as a login process and shell A Linux system can also include a modern X Window System implementation Including a full-featured desktop environment, such as GNOME Overview of Operating Systems and Kernels (1) Many users consider whatever they see on the screen to be the operating system. Technically speaking, the operating system is considered the parts of the system responsible for basic use and administration Includes the kernel and device drivers, boot loader, command shell or other user interface, and basic file and system utilities The term system refers to the operating system and all the applications running on top of it The user interface is the outermost portion of the operating system The kernel is the innermost Overview of Operating Systems and Kernels (2) The kernel is the core internals The software that provides basic services for all other parts of the system, manages hardware, and distributes system resources Sometimes referred to as the supervisor, core, or internals of the operating system. Typical components of a kernel are: Interrupt handlers to service interrupt requests A scheduler to share processor time among multiple processes A memory management system to manage process address spaces System services such as networking and interprocess communication Overview of Operating Systems and Kernels (3) On modern systems with protected memory management units The kernel typically resides in an elevated system state compared to normal user applications This includes a protected memory space and full access to the hardware This system state and memory space is collectively referred to as kernel-space User applications execute in user-space See a subset of the machine's available resources Unable to perform certain system functions, directly access hardware, or otherwise misbehave Overview of Operating Systems and Kernels (4) When executing the kernel, the system is in kernelspace executing in kernel mode Applications running on the system communicate with the kernel via system calls An application typically calls functions in a library, e.g. the C library As opposed to normal user execution in user-space executing in user mode In turn rely on the system call interface to instruct the kernel to carry out tasks on their behalf Some library calls have a one-to-one relationship with the kernel The open() library function does nothing except call the open() system call Overview of Operating Systems and Kernels (5) Still other C library functions make no use of the kernel at all When an application executes a system call, the kernel is executing on behalf of the application The application executes a system call in kernel-space The kernel is running in process context This relationship that applications call into the kernel via the system call interface is Such as strcpy() The fundamental manner in which applications get work done The kernel also manages the system's hardware Overview of Operating Systems and Kernels (6) All systems that Linux supports, provide the concept of interrupts Interrupts are identified by a number The kernel uses the number to execute a specific interrupt handler to process and respond to the interrupt As you type, the keyboard controller issues an interrupt to let the system know that there is new data in the keyboard buffer The kernel notes the interrupt number being issued and executes the correct interrupt handler The interrupt handler processes the keyboard data and lets the keyboard controller know it is ready for more data When hardware wants to communicate with the system, it issues an interrupt asynchronously interrupting the kernel The kernel can usually disable interrupts To provide synchronization Overview of Operating Systems and Kernels (7) In Linux, the interrupt handlers do not run in a process context Either all interrupts or just one specific interrupt number They run in a special interrupt context that is not associated with any process This special context exists solely to let an interrupt handler quickly respond to an interrupt, and then exit In Linux, each processor is doing one of three things at any given moment: In kernel-space, in process context, executing on behalf of a specific process In kernel-space, in interrupt context, not associated with a process, handling an interrupt In user-space, executing user code in a process Linux Versus Classic Unix Kernels (1) Owing to their common ancestry and same API, modern Unix kernels share various design traits With few exceptions, a Unix kernel is typically a monolithic static binary Unix systems typically require a system with a paged memory-management unit It exists as a large single-executable image that runs in a single address space Enables the system to enforce memory protection Provides a unique virtual address space to each process Characteristics that differ between the Linux kernel and other Unix variants Linux supports the dynamic loading of kernel modules Linux Versus Classic Unix Kernels (2) Linux has symmetrical multiprocessor (SMP) support Although many commercial variants of Unix now support SMP, most traditional Unix implementations did not The Linux kernel is preemptive Although the Linux kernel is monolithic, it is capable of dynamically loading and unloading kernel code on demand Unlike traditional Unix variants, the Linux kernel is capable of preempting a task even if it is running in the kernel Linux takes an interesting approach to thread support It does not differentiate between threads and normal processes Linux Versus Classic Unix Kernels (3) To the kernel, all processes are the same some just happen to share resources Linux is free in every sense of the word Modifications must solve a specific real-world problem Have a sane design Have a clean implementation Linux Kernel Versions (1) Linux kernels come in two flavors Stable or development Stable kernels are production-level releases suitable for widespread deployment Linux kernels distinguish between stable and development kernels with a simple naming scheme The first value is the major release The second is the minor release The third is the revision An optional fourth value is the stable version For the minor release, an even number is stable An odd number is development Linux Kernel Versions (2)