DOC PREVIEW
U of I CS 498 - An Overview of Linux Kernel Structure

This preview shows page 1-2-16-17-18-34-35 out of 35 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 498 Lecture 4An Overview of Linux Kernel StructureJennifer HouDepartment of Computer Science University of Illinois at Urbana-ChampaignReading: Chapter 1-2, The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux KernelOutlineOverview of the Kernel StructureActivities in the Linux KernelLockingKernel Modules/proc File SystemMemory ManagementTimingStructure of Linux KernelApplications and toolsSystem callsProcessmanagementMemorymanagementFilesystemsDevicedriversNetworkMultitaskingVirtualmemoryFiles, directories Device accessNetworkfunctionalityUser spacecomponentFunctionalitySchedulerArchitecturespecificcodeMemorymanagerFile systemtypesBlockdevicesCharacterdevicesNetworkprotocolsNetworkdriversCPU RAMHard diskCD, floppyTerminalsNetworkadapterSoftwaresupportHardwaresupportHardwareOverview of the Kernel StructureProcess managementz The scheduler handles all the active, waiting, and blocked processes.Memory managementz Is responsible for allocating memory to each process and for protecting allocated memory against access by other processes.File systemz In UNIX, almost everything is handled over the file system interface.z Device drivers can be addressed as filesz /proc file system allows us to access data and parameters in the kernelOverview of the Kernel StructureDevice driversz Abstract from the underlying hardware and allow us to access the hardware with well-defined APIsz The use of kernel modules allow device drivers to be dynamically loaded/unloadedNetworksz Incoming packets are asynchronous events and have to be collected and identified, before a process can handle them.z Most network operations cannot be allocated to a specific process. Instead, interrupts and timers are used extensively.Features of Linux KernelIs a Monolithic kernelz The entire functionality is contained in one kernel. z In contrast, in microkernels (e.g., Mach kernel and Windows NT), only memory management, IPC, and other hardware-related functions are contained in the kernel. The remaining functionality is moved to independent processes/threads running outside the OS. z + accessing resources directly from within the kernel, avoiding expensive system calls and context switches.z - OS becomes quite complex.z - The development of new drivers is difficult because of the lack of appropriate interface definitions.Feature of Linux KernelA cure is the use of kernel modulesz Linux allows kernel modules to be dynamically loaded into (removed from) the kernel at run time.z This is achieved with the use of well-defined interfaces, e.g., register_netdev(), register_chrdev(), register_blkdev().z The components shown on dark backgrounds provide interfaces for dynamically registering new functionality.z The run-time performance is guaranteed by having modules run in protected kernel mode.Activities in the Linux KernelActivities – Processes and System CallsProcesses operate exclusively in the user address space, and can only access the memory allocated to them.z Violation leads to exceptions.When a process wants to access devices or use a functionality in the kernel Î system call.z The control is transferred to the kernel, which executes the system call on behalf of the user process.Processes can be interrupted voluntarily (wait on semaphore or sleep) or involuntarily (interrupt).Other Forms of ActivitiesHardware interrupts (hardware IRQs)Software interrupts (software IRQs)TaskletsYesNoTaskletYesYesSoft IRQYesNoHW IRQDifferent ActivitiesSame ActivityCan a single activity or multiple instances of an activity be Execuated on multiple processors?Can an Activity be Interrupted by Other Activities?+++Process+++System call--+Tasklet--+Software IRQ--+/-Hardware IRQTaskletSoft-IRQHW-IRQInterrupts – Hardware IRQsPeripherals use hardware interrupts to inform OS of events (e.g., a packet has arrived at the network adapter) Æ an interrupt handling routine is called.The handling routine for a specific interrupt can be registered (de-registered) by register_irq() (free_irq()).Fast interruptsz have a very short handling routine (that cannot be interrupted).z Are specified by the flag SA_INTERRUPT in request_irq().Slow interruptsz Have a longer handling routine and can be interrupted by other interrupts during their execution.in_irq() (include/asm/hardirq.h) can be used to check whether or not the current activity is an interrupt-handling routine.Software Interrupts Not every operation that needs to be executed in an interrupt can be completed in a few instructions (e.g., a packet that arrives at a network adapter).To keep interrupt handling short, the routine is usually divided into two parts:z Top-half: handles the most important tasks (e.g., copying the arrived packet to a kernel buffer queue waiting for detailed handling later)z Bottom-half: handles non-time critical operations. It is being scheduled for execution right after the top half is executed (e.g., when a packet arrives, the bottom half is run as a software interrupt NET_RX_SOFTIRQ).Software InterruptsWhen a system call or a hardware interrupt terminates, the scheduler calls do_softirq().do_softirq() schedules software interrupts for execution.A maximum of 32 software interrupts can be defined in Linux.z NET_RX_SOFTIRQ and NET_TX_SOFTIRQ are two software interrupts.Multiple software interrupts can run concurrently, and hence need to be reentrant Æ If critical sections exist in a software interrupt, they have to be portected by locks.in_softirq() (include/asm/softirq.h) can be used to check whether or not the current activity is a software interrupt.TaskletsA more formal mechanism of scheduling software interrupts (and other tasks).z The macro DECLARE_TASKLET(name, func,data)z name: a name for the tasklet_struct data structurez func: the tasklet’s handling routine.z data: a pointer to private data to be passed to func().z tasklet_schedule(&tasklet_struct) schedules a tasklet for execution.z tasklet_disable() stops a tasklet from running, even if it has been scheduled for execution.z tasklet_enable() reactivates a deactivated tasklet.Tasklet Example#include <linux/interrupt.h>/* Handling routine of new tasklet */void test_func(unsigned long);/* Data of new tasklet */char test_data[] = “Hello, I am a test tasklet”;DECLARE_TASKLET(test_tasklet, test_func, (unsigned long) &test_data);void test_func(unsigned long data){printk(KERN_DEBUG, “%s\n”, (char *) data);}….tasklet_schedule(&test_tasklet);LockingBit


View Full Document

U of I CS 498 - An Overview of Linux Kernel Structure

Documents in this Course
Lecture 5

Lecture 5

13 pages

LECTURE

LECTURE

39 pages

Assurance

Assurance

44 pages

LECTURE

LECTURE

36 pages

Pthreads

Pthreads

29 pages

Load more
Download An Overview of Linux Kernel Structure
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view An Overview of Linux Kernel Structure and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view An Overview of Linux Kernel Structure 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?