180 likes | 185 Views
作業系統 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
E N D
作業系統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
Introduction to Linux (1) • Linux was developed by Linus Torvalds in 1991 as an operating system for computers using the Intel 80386 microprocessor • At the time was a new and advanced processor • Linux is a full-fledged operating system running on • 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 • It is not Unix • 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 • 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 kernel-space executing in kernel mode • As opposed to normal user execution in user-space executing in user 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 • 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 • Such as strcpy() • 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 • 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 • When hardware wants to communicate with the system, it issues an interrupt asynchronously interrupting the kernel • 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 • The kernel can usually disable interrupts • To provide synchronization
Overview of Operating Systems and Kernels (7) • Either all interrupts or just one specific interrupt number • In Linux, the interrupt handlers do not run in a process context • 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 • It exists as a large single-executable image that runs in a single address space • Unix systems typically require a system with a paged memory-management unit • 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) • Although the Linux kernel is monolithic, it is capable of dynamically loading and unloading kernel code on demand • 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 • 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