610 likes | 857 Views
커널 구조적 관점에서 본 리눅스. 1999. 5. 3. ETRI 운영체제연구팀 김 해 진. Contents. Introduction OS Kernel Architecture Comparison Integrated Kernel Architecture Microkernel Architecture Semi-microkernel Architecture Linux Features (from architectural view ) Linux Kernel Internals
E N D
커널 구조적 관점에서 본 리눅스 1999. 5. 3. ETRI 운영체제연구팀 김 해 진
Contents • Introduction • OS Kernel Architecture Comparison • Integrated Kernel Architecture • Microkernel Architecture • Semi-microkernel Architecture • Linux Features (from architectural view ) • Linux Kernel Internals • Directions and Considerations for Kernel Architecture • Concluding Remarks
Hardware Operating System • Operating System vs. Operating Environments Application Application Application Application Programming Interface(API) System calls, Libraries and Commands System Call Interface Operating System Kernel HW-OS Interface (eg. Intel MP-Spec)
API API Server Server Server Integrated Kernel Microkernel Hardware Hardware OS Kernel Approaches • Integrated Kernel Approach • “Monolithic kernel” • Function calling • Eg) UnixWare, Solaris, AIX, HP-UX, DG-UX, IRIX, Linux, etc • Microkernel Approach • Serverization based on MK • Message passing • Eg) Cray UNICOS/mk, CMU Mach SunSoft Chorus, Digital UNIX, ETRI MISIX, Linux Mk, etc OS Personality
Integrated Kernel Architecture • Traditional UNIX Architecture User Programs User Programs Trap User level Libraries Kernel level System Call Interface File System Management IPC Buffer Cache Process Mgt. Scheduling Memory Mgt. Device Drivers Hardware Control (Interrupts handling, etc) Hardware
Integrated Kernel Architecture (cont.) • Design Goals of UNIX • Interactive timesharing system designed by programmers, and for programmers • Model of a group of experienced programmers working together • What good programmers want in a system ? • Be simple, elegant, and consistent • Be powerful and flexible • UNIX has extensible facilities for peoples who are related with sophisticated, and are engaged in quite complex software development. • Different from the personal computer model of a single beginner working alone with a word processor • Design Goals of LINUX • No specific goals from the kernel architecture perspective • Basically ‘a variant of UNIX’ from the viewpoints of concepts, abstractions, features, and the fundamental kernel architecture • Philosophy of ‘Copyleft’
Integrated Kernel Architecture (cont.) • UNIX, ‘is it dumping ground’ ? • Critique against UNIX Kernel by NT people • “… Unix kernel has become a ‘dumping ground’ for virtually every new feature or facility …. Abstraction have become mixed and information has been jumbled.” • “There is a common fate of popular operating system during their multi-decade lifetimes. They are pushed to their architectural limits, extended, and then pushed again.” • Thus, MS insist that NT kernel seeks to shield the NT executive from an eventual “dumping ground” fate. • In case of LINUX, what can we say ?
User processes User space System V Emulator Software Emulator Layer HP/UX Emulator Other Emulator 4.3 BSD Emulator Memory Mgt Process Mgt. Comm. Mgt. I/O Mgt. Kernel space Microkernel Architecture • Mach Microkernel Process Address space Thread Process port Bootstrap port Exception port Registered ports Kernel
System Servers PM FM STM BSQ PNM DPS DDA SDA KM PIPE DLD IPCM UM Chorus Microkernel Interprocess Communication Memory Management Threads/Actors Runtime Env. H/W Dependent Supervisor (H/W Dependent) Microkernel Architecture • Chorus Microkernel Chorus Microkernel
User processes Software Emulator Layer Linux Personality Memory Mgt Process Mgt. Comm. Mgt. I/O Mgt. Mach MK Microkernel Architecture (cont.) • MK based Linux & Linux Microkernel • MkLinux • Linux Personality on top of Mach microkernel • Apple Computer is collaborating with the Open Group Research Institute • Currently available for Apple PowerMac, Intel x86, and HP PA-RISC platforms • L4Linux • Dresden Operating Systems group • Currently available for Intel x86, MIPS, and Digital Alpha platforms
Semi-Microkernel Architecture • Windows NT Architecture POSIX Client OS/2 Client Win32 Client Logon Process Applications POSIX Server OS/2 Server Message Protected Subsystem (Servers) Win32 Server Security Server User mode Trap Kernel mode I/O Manager System Services File System Object Manager Security Ref. Monitor LPC Facility VM Mgt. Process Manager Cache Manager NT Executive Device Drivers Network Drivers Kernel Hardware Abstraction Layer(HAL) HW Control Hardware (Source : Inside Windows NT)
Semi-Microkernel Architecture (cont.) • Design Goals of Windows NT: Extensible OS • Extensibility • The code must be written to comfortably grow and change as market requirement change. • Portability • As dictated by market goals, the code must move easily from one processor to another • Reliability and robustness • The system should be protect itself from both internal malfunction and external tampering. It should behave predictably at all times. • Compatibility • Although NT should extend existing technologies, its user interface and APIs should be compatible with existing MS systems. • Performance • Within the constraints of the other design goals, the system should be as fast and responsive as possible on each hardware platform.
Semi-Microkernel Architecture (cont.) • NT, ‘is it technically brand-new’ ? • Major concepts and features from UNIX • David Cutler : He was instrumental in designing DEC OS, eg. VAX/VMS, RSX-11M for PDP-11 machine. He is a director in Windows NT Development. • Mark Lucovsky : He has written process structure for both a UNIX system and an object-oriented operating system. He designed NT process manager. • Major concepts and features from Mach OS • Richard Rashid : He and his colleagues created Mach operating system at CMU, and later joined MS as a Director of Research in late 1991. Windows NT has many similarities with Mach. • Object-oriented implementation and some improvements • Windows GUI
Semi-Microkernel Architecture (cont.) • Worrying-about the future of NT 5.0 (Windows 2000) • NT 5.0 Source Line Size(Source: Computer World, August ‘98) • NT 5.0’s size means that “it’s more than just an upgrade. The big concern with NT is that it’s been so long since 4.0. It won’t be an evolutionary path.” • NT 5.0 is going to be bigger than IBM’s MVS - It’s surprising ! • “NT 5.0 is growing because so many features are being added to it”. • Heavyweight • NT 5.0 will be “the big dog on the block” when it comes to lines of code. Here’s how it will stack up: • UNIX : 10 million to 15 million • NetWare 5.0 : 10 million • NT 4.0 : 16 million • NT 5.0 : 25 million to 40 million • The more stuff they dump in there, the more issues they’re going to have to deal with.
Linux Features • Linux meet almost all the demands nowadays made of a modern, Unix type OS. • Multitasking: several programs running at the same time. • Multiuser: several users on the same machine at the same time • Multiplatform: runs on many different CPUs, not just Intel. • Multiprocessing: • SMP support is available on the Intel and SPARC platforms • Linux is used in several loosely-coupled MP applications, including Beowulf systems and the Fujitsu AP1000+ SPARC-based supercomputer • Multithreading: has native kernel support for multiple independent threads of control within a single process memory space.
Linux Features (cont.) • Runs in protected mode on the 386 • Has memory protection between processes, so that one program can't bring the whole system down. • Demand loads executables: Linux only reads from disk those parts of a program that are actually used. • Shared copy-on-write pages among executables. • This means that multiple process can use the same memory to run in. When one tries to write to that memory, that page (4KB piece of memory) is copied somewhere else. Copy-on-write has two benefits: increasing speed and decreasing memory use. • Virtual memory using paging to disk • to a separate partition or a file in the file system, or both, with the possibility of adding more swapping areas during runtime. A total of 16 of these 128 MB (2GB in recent kernels) swapping areas can be used at the same time, for a theoretical total of 2 GB of useable swap space. It is simple to increase this if necessary, by changing a few lines of source code.
Linux Features (Cont.) • A unified memory pool for user programs and disk cache, so that all free memory can be used for caching, and the cache can be reduced when running large programs. • Dynamically linked shared libraries (DLL's), and static libraries too, of course. • Does core dumps for post-mortem analysis, allowing the use of a debugger on a program not only while it is running but also after it has crashed. • Mostly compatible with POSIX, System V, and BSD at the source level. • Through an iBCS2-compliant emulation module, mostly compatible with SCO, SVR3, and SVR4 at the binary level.
Linux Features (cont.) • All source code is available, including the whole kernel and all drivers, the development tools and all user programs; also, all of it is freely distributable. • Plenty of commercial programs are being provided for Linux without source, but everything that has been free, including the entire base operating system, is still free. • POSIX job control. • Pseudo terminals (pty's). • 387-emulation in the kernel so that programs don't need to do their own math emulation. Every computer running Linux appears to have a math coprocessor. • Of course, if your computer already contains an FPU, it will be used instead of the emulation, and you can even compile your own kernel with math emulation removed, for a small memory gain. • Support for many national or customized keyboards, and it is fairly easy to add new ones dynamically.
Linux Features (cont.) • Multiple virtual consoles: • Several independent login sessions through the console, you switch by pressing a hot-key combination (not dependent on video hardware). These are dynamically allocated; you can use up to 64. • Supports several common file systems • Linux has MINIX, XENIX, and all the common system V file systems • Linux has an advanced file system of its own, which offers file systems of up to 4 TB, and names up to 255 characters long. • Transparent access to MS-DOS partitions (or OS/2 FAT partitions) via a special file system • You don't need any special commands to use the MS-DOS partition, it looks just like a normal Unix file system (except for funny restrictions on filenames, permissions, and so on). • MS-DOS 6 compressed partitions do not work at this time without a patch (dmsdosfs). • VFAT (WNT, Windows 95) support and FAT-32 is available in Linux 2.0
Linux Features (cont.) • Special file system called UMSDOS which allows Linux to be installed on a DOS file system. • Read-only HPFS-2 support for OS/2 2.1 • HFS (Macintosh) file system support is available separately as a module. • CD-ROM file system which reads all standard formats of CD-ROMs. • TCP/IP networking, including ftp, telnet, NFS, etc. • Appletalk server • NetWare client and server • LAN Manager/Windows Native (SMB) client and server • Many networking protocols • Protocols available in the latest development kernels include TCP, IPv4, IPv6, AX.25, X.25, IPX, DDP (Appletalk), Netrom, and others. • Stable network protocols included in the stable kernels currently include TCP, IPv4, IPX, DDP, and AX.25.
Process Management • Linux Processes
Process Management (cont.) • Identifiers • Linux, like all Unix uses user and group identifiers • Check for access rights to files and images in the system • Scheduling • Normal and real time process • Policy • round robin, first in first out • priority based preemptive scheduling
Process Management (cont.) • Files
Process Management (cont.) • Virtual Memory
Process Management (cont.) • Times and Timers • Each clock tick, the kernel updates the amount of time that the current process has spent in system and in user mode.
Process Management (cont.) • Executing Programs • ELF object file format, designed by the Unix System Lab. • Script Files • Script files are executables that need an interpreter to run them. • For example wish, perl and command shells such as tcsh
Interprocess Communication • Linux Supports a number of Inter-Process Communication (IPC) Mechanisms • Signals • Pipes
Interprocess Communication (cont.) • System V IPC • Message Queues • Semaphores • Shared Memory
Memory Management • An Abstract Model of Virtual Memory
Memory Management (cont.) • Caches • Buffer Cache • The buffer cache contains data buffers that are used by the block device drivers. • Page Cache • Used to speed up access to images and data on disk. • Swap Cache • Only modified (or dirty) pages are saved in the swap file. • Hardware Caches • One commonly implemented hardware cache is in the processor; a cache of Page Table Entries.
Memory Management (cont.) • Linux Page Tables • Linux assumes that there are three levels of page tables • Linux uses the same page table manipulation code for the Alpha, x86 processor
Memory Management (cont.) • Page Allocation and Deallocation • Linux uses the Buddy algorithm to effectively allocate and deallocate blocks of page. • Memory Mapping • Linking an executable image into a processes virtual address space.
Memory Management (cont.) • Demand Paging • The Linux Page Cache
Memory Management (cont.) • Swapping Out and Discarding Pages • The kernel swap daemon uses to reduce the number of physical pages being used by the system: • Reducing the Size of the Page and Buffer Caches • Swapping Out System V Shared Memory Pages • Swapping Out and Discarding Pages
Device Drivers • Polling and Interrupts • Polling the device means reading its status register until the device’s status changes to indicate that it has completed the request. • Interrupt • the device informs the CPU via an interrupt channel that it has finished an operation.
Device Drivers (cont.) • Direct Memory Access (DMA) • DMA controller allows devices to transfer data to or from the system’s memory without the intervention of the processor. • Interfacing Device Drivers with the Kernel • Character Devices • processed sequentially and are therefore accessed without buffer
Device Drivers (cont.) • Block Devices • Random access • Accesses are handled transparently by the cache • Buffer Cache Block Device Requests
Device Drivers (cont.) • Hard Disks • SCSI, IDE Disks
Device Drivers (cont.) • SCSI Data Structures
Device Drivers (cont.) • Network Devices • device data structure • Name • /dev/ethN Ethernet devices • /dev/slN SLIP devices • /dev/pppN PPP devices • Bus Information • Interface Falgs • describe the characteristics and abilities of the network device. • Protocol Information • Packet Queue • waiting to be transmitted on this network device. • Support Functions • standard set of routines.
File System • The Second Extended File System (EXT2) • The most successful file system so far in the Linux community. • Physical Layout of the EXT2 File System
File System (cont.) • EXT2 Inode
File System (cont.) • EXT2 Directory
File System (cont.) • The Virtual File System (VFS) • A Logical Diagram of the Virtual File System
File System (cont.) • A Mounted File System
File System (cont.) • The Buffer Cache • The dbflush Kernel Daemon • The update command