Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to the Linux Kernel 國立中正大學 資訊工程研究所 羅習五 老師.

Similar presentations


Presentation on theme: "Introduction to the Linux Kernel 國立中正大學 資訊工程研究所 羅習五 老師."— Presentation transcript:

1 Introduction to the Linux Kernel 國立中正大學 資訊工程研究所 羅習五 老師

2 Linux is a Unix-like system, but it is not Unix Although 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

3 GNU/Linux The basics of a Linux system are the kernel, C library, compiler, toolchain, and basic system utilities, such as a login process and shell. Strictly speaking, after all, the term Linux refers to only the kernel. One of Linux's most interesting features is that it is not a commercial product

4 a free or open source software The Linux kernel is licensed under the GNU General Public License (GPL) version 2.0

5 GPL ver. 1 目的:防止那些阻礙自由軟體的行為 – 軟體發布者只發布可執行的二進制代碼而不發 布具體原始碼 – 軟體發布者在軟體許可加入限制性條款 因此按照 GPLv1 , – 發布了可執行的二進制代碼,就必須同時發布 可讀的原始碼 – 並且在發布任何基於 GPL 許可的軟體時,不能 添加任何限制性的條款 http://zh.wikipedia.org/zh- tw/GNU%E9%80%9A%E7%94%A8%E5%85%AC%E5%85%B1%E8%AE%B8%E5%8F%AF%E8%AF% 81

6 GPL ver. 2 如果哪個人在發布源於 GPL 的軟體的時候,同 時添加強制的條款,以在一定程度上保障和 尊重其它一些人的自由和權益那麼他將根本 無權發布該軟體。 (換句話說: GPLv2 與專利是相衝突的) http://zh.wikipedia.org/zh- tw/GNU%E9%80%9A%E7%94%A8%E5%85%AC%E5%85%B1%E8%AE%B8%E5%8F%AF%E8%AF% 81

7 Kernel components 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 inter- process communication

8 Kernel mode and kernel space The kernel includes a protected memory space and full access to the hardware. This system state and memory space is collectively referred to as kernel-space A user process executes in – User-space – kernel-space

9 kernel-space The kernel typically resides in an elevated system state compared to normal user applications. – a protected memory space – full access to the hardware This system state and memory space is collectively referred to as kernel-space

10 user-space They see a subset of the machine’s available resources and can perform certain system functions

11 root & normal user kernel model & user mode

12 Function calls and OS Eventually call a system call – i.e., eventually calls write() to write the data to the console Always call a system call – some library calls have a one-to-one relationship with the kernel. Other C library functions – such as strcpy(), should (you hope) make no use of the kernel at all.

13 System calls Applications running on the system communicate with the kernel via system calls An application typically calls functions in a library When an application executes a system call, we say that the kernel is executing on behalf of the application.

14 Devices and OS When hardware wants to communicate with the system, it issues an interrupt that asynchronously interrupts the kernel. – Interrupts are identified by a number. – The number is used to identify a interrupt handler Linux’s interrupt handlers do not run in a process context. Instead, they run in a special interrupt context that is not associated with any process.

15 Interrupts When hardware wants to communicate with the system, it interrupts the kernel A number identifies interrupts and the kernel uses this number to execute a specific interrupt handler

16 Summary: Executing contexts The modes a CPU executes in 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

17 The modes a CPU executes in Top halve (including bottom half) Process context ISR CTX User space Kernel space

18 Linux Versus Classic Unix Kernels Linux supports the dynamic loading of kernel modules. Linux has symmetrical multiprocessor (SMP) support. – Including UMA and NUMA The Linux kernel is preemptive Linux does not differentiate between threads and processes. – by invoking “clone()”

19 A preemptive OS (non preemptive kernel) initiate a context switch when the OS switch to user mode. A preemptive kernel can also initiate a context switch in kernel mode to satisfy the scheduling policy. A preemptive kernel

20 Linux Kernel Versions

21 The kernel version It is also interesting to note that starting with kernel 2.6.23, both architectures (IA32 & AMD64) are unified to the generic x86 architecture within the Linux kernel. The textbook discusses the 2.6.34 kernel.

22 Before We Begin This course is about the Linux kernel: how it works, why it works, and why you should care. Do make a Linux kernel – Understand menu items listed in “make menuconfig” – Read documents in /“linux-src”/Documentation Enjoy your Linux life

23


Download ppt "Introduction to the Linux Kernel 國立中正大學 資訊工程研究所 羅習五 老師."

Similar presentations


Ads by Google