Font Size: a A A

Study On Interrupt Mechanism And Improve Real-time Performance In The Linux 2.6 Kernel

Posted on:2008-04-14Degree:MasterType:Thesis
Country:ChinaCandidate:H X LiFull Text:PDF
GTID:2178360212496238Subject:Computer application technology
Abstract/Summary:PDF Full Text Request
Having been developed for ten years, Linux had formed 3 main editions:standerd DeskTop Linux, miniaturized Embedded Linux and Real-time Linux.Linux is much widely used in embedded domain than other environments.As a famous open source software, Linux is compatible with embeddedoperating system. The stable kernel, powerful ability for network and freeapplication softwares available, all these factors meet the requirements of newgeneration embedded operating system. Linux gains more power when combineswith new technology in embedded field. But Linux was designed as atime-sharing operating system at the begin time, which focused on getting the bestaverage performance. In most cases, what an embedded system need is a real-timeoperating system, so the standard Linux can not meet the requirements. A lot ofwork has to be carried out to improve real-time performance. Improving onreal-time support of Linux system is becoming a hot point of research on real-timeoperating system.Up to now, many ways are applied to improve real-time performance ofLinux kernel, some of them are relatively successful. These ways focused on thefollowing fieilds: add rescheduling points, improve its preempt ability; addanother kernel to take over the standard Linux kernel, make the added kerneltaking care of real-time Interrupts; modify the standard Linux Interrupts, makeInterrupt handled as a task.This paper studies the Interrupt mechanism of Linux kernel. The Interruptmechanism of Linux kernel is nearly the same as in the other architectures, but itis closely related to real-time performance. In standard Linux, Interrupts have thehighest priority, and Interrupts may happen at any time, even realtime tasks withthe highest scheduling priority can not prevent themselves from being disturbedfor the CPU to handle Interrupts, so these tasks may not complete in expectedtime. This paper analyses the realization of tasked Interrupts in Ingo's RT patch.The main point is: make a thread for each Interrupt. The Interrupt threads are inthe same level with current tasks' threads, and can be scheduled just by the valueof the thread's real-time priority.Using the reference of tasked Interrupt, this paper brings out a project to improve the real-time performance. This project also makes Interrtupts tasked inthe initialize phase, and endows each thread with a real-time priority. Thereal-time priority of IRQ 0 is specified as 49, IRQ 1 is specified as 48, as far as 25.So the lowest priority is 25. If one Interrupt needs to be real-time handled, it canbe announced as IRQF_NODELAY, so it will not be threaded. For example, thesystem clock, because it is used to maintain system time and timer, it should notbe threaded.When Interrupt comes, CPU will carry out the function do_IRQ to handle it.The function do_IRQ firstly deals with the work related to specific architecture,then, it will call the function __do_IRQ. The function __do_IRQ will do a seriesof judgements: based on the result of comparison between the current task'sreal-time priority and the Interrupt thread's real-time priority, assign a suitabletime for Interrupt to execute. The way is to do the comparison in the executionfunction of the Interrupt, handle differently for each different result. So it can beassured that the high real-time priority task will not be disturbed in its workingprocess, and the emergent Interrupt will stop the low real-time priority task toexecute itself.In the standard Linux kernel, Interrupts have the highest priority. Thereal-time task can be disturbed by Interrupts in its working process, so theresponse time of the task will be too long. To solve this problem, Ingo's RT patchbrings out the idea of tasked Interrupts. But when the Interrupt thread's priority ishigher than the current thread's, the Interrupt thread will also be woken up, andjoin in the scheduling process, this will obviously increase the Interrupt's responsetime. In the project of this paper, add the comparison between the current task'sreal-time priority and the Interrupt thread's, if the current thread is not a real-timeone, or its priority is lower than the Interrupt thread's, directly call the user'sInterrupt service routine, instead of waking up the Interrupt thread. In this way,the Interrupt's response time will be improved.To estimate if the idea mentioned above is carried out correctlly in the project,the paper performs a correctness analysis. In the first experiment, use theinstruction "INT n" to simulate different software Interrupts, print out the mainexecution paths of the Interrupts, according to the result of comparison, it isproved that the idea mentioned above is carried out correctlly. In the secondexperiment, also use the instruction "INT n" to simulate software Interrupt, anduse the function rdtsc to time the process, then, calculate the Interrupt's response time. It is proved that the Interrupt's response time of this project is lower than theIngo's.In addition, use a file named realfeel to test the kernel's scheduling latency,the tested kernel editions are the standered Linux2.6.18 kernel and theLinux2.6.18 kernel with Ingo's RT patch. Based on the results, we can figure outthat the scheduling latency of the latter one is reduced sharply.The paper also introduces the embedded system construction. Samsungs3c2410 microprocessor is used in our platform, and it has become a standardplatform supported by Linux. Ever since version 2.6.10,Linux can directly run onit after a few modifications, which just provide necessary information about Nandflash to kernel. To make Linux configured properly, the standard configuration ofSMDK2410 can help a lot.Embedded systems are different in their hardware configuration. Abootloader is usually designed to initialize hardware and boot operating system,and it has a tight tie with special platform. So each embedded system needs abootloader of its own. After hardware initialization, the bootloader moves Linuxkernel to proper memory area and prepares booting params for it, and then leavesthe Linux kernel to take control of the left process.Embedded file system is usually constructed on flash memory, which makesthe Linux traditional file systems like ext2 unsuitable. So, special file system isneeded for embedded system. According to system's requirement, cramfs isfinally choosed as system's root file system. Cramfs is designed by Linus Torvalds,the founder of Linux, and is a compressable and readonly file system. Cramfs hasa compressed rate up to 2:1, so more memory can be left for system. Theread-only characteristic prevents files from being destroyed and is good forimproving system's reliability. Cramfs can reach a high speed when read and write.After adding a user application toolkit--busybox on the root file system, theembedded system is successfully constructed.In conclusion, this paper attempts to improve the Linux's real-timeperfomance through modifying the Linux kernel directly, it brings up a feasiblereal-time project, after a test, it can be proved that this project improves thereal-time performance on a certain extent based on standard Linux. In addition,this paper realizes the embedded system construction on the ARM9 platform.
Keywords/Search Tags:Performance
PDF Full Text Request
Related items