Smartphone Operating System (779883), страница 14
Текст из файла (страница 14)
(Usually, if it is not serviced in this time, some event is lostor performance is degraded seriously.) The interrupt execution time isthe time required to service the interrupt. Interrupts with a short interruptlatency time must have a short interrupt service time.Interrupts are serviced in a kernel by an interrupt service routine (ISR).There are many ISRs (because there are many types of interrupt) and onlya few need to be recognized by the kernel at any given time.
Therefore,most kernel designs maintain a vector table that contains the interrupt anda pointer to its ISR. This table is finite and is coordinated with the numberof possible interrupt sources. When an interrupt occurs, the address ofthe ISR is looked up in the vector table and that ISR is called.It is important to note that, while an ISR runs on the kernel side ofan operating system, the context – or state – of the system cannot beassumed.
An interrupt can occur at any time and the system could be inany state when the kernel is interrupted. This inability to access any kindof context information restricts what can be done in an ISR.Interrupts are typically implemented by an operating in several phases:1.The preamble phase saves the context of the executing process andprepares to execute the ISR.2.The second phase determines which code to execute on behalf of theinterrupt request (it dispatches the interrupt).
This is either a built-inroutine (in the case of a system class) or an external piece of code.3.The third phase is the execution of the system call or ISR code,handled by privileged-mode code. Typically, this phase is itselfinterruptible.4.The last phase implements the closure of the process (the ‘postamble’phase). This typically amounts to a reversal of the preparatory phase:56KERNEL STRUCTUREthe context is switched back to the interrupted process or storage isrestored and execution resumes where it left off.3.4 Completing the Kernel Design in Symbian OSThe smartphone platform is a unique one.
It requires many real-timeservices, but also must provide an environment that is similar to a desktopsystem in its richness. In order to respond to both of these requirements,the Symbian OS kernel has a more complicated structure than the oneoutlined earlier in this chapter. In this section, we expand our look atthe structure of the Symbian OS kernel by fleshing out a complete kernelstructure.The kernel structure is shown in Figure 3.2. It is organized in relationship to how system calls are made, that is, the path a user-mode programmust travel to execute privileged code in the kernel.The Symbian OS model starts by working with the peripheral hardware.
Several kernel components communicate directly with a smartphone’s hardware.• Device drivers, the interface for program code to work with devices(see Chapter 2), are split into two pieces in Symbian OS: the physical device driver (PDD) interfaces directly with the hardware andUser threadFile serverEFSRVUser modeHALPersonality layerRTOSPrivilegedUser library EUSERMicrokernel serversNanokernelSymbian OS kernelMemory modelASSPPeripheral hardwareFigure 3.2 Structure of the Symbian OS kernelLDDPDDExtensionCOMPLETING THE KERNEL DESIGN IN SYMBIAN OS57the logical device driver (LDD) presents an interface to upper layersof software.
In addition, the kernel can interact directly with hardware through the application-specific standard product (ASSP), whichimplements a number of components through a standard interface (soa specific driver is not needed). Finally, real-time components of theoperating system – those specifically involved in phone calls – canalso interact directly with the phone hardware when they run in aspecial mode (called the ‘personality layer’).• The memory model used by the operating system is a model of howmemory is organized on a device and how the operating system workswith it. We deal with memory management and memory models inChapter 7. Several memory models are possible in Symbian OS andthese are implemented by the Symbian OS kernel.• The Symbian OS kernel relies on the nanokernel, but is separatefrom the real-time portions of the operating system.
It implements thevarious memory models that platforms require.• The nanokernel implements the most basic and primitive parts ofSymbian OS and is used by the phone part of the operating system aswell as the larger kernel layer.• The real-time OS and personality layers are specifically designedto implement phone functionality.
The RTOS implements the GSMfunctions of a smartphone in direct connection with the hardware.The personality layer allows a smartphone manufacturer to use adifferent implementation of phone function (say, analog functionality)by using the implementation from another operating system or deviceand using a personality layer to connect that implementation to theGSM functionality of the smartphone.
The personality layer then actsas an interpreter, translating the non-GSM implementation into animplementation the smartphone can understand.• User-mode layers include microkernel servers as well as user applications. As we have discussed before, these interact with the SymbianOS kernel to request and initiate kernel-mode operations.There are many paths through the Symbian OS kernel structure. Auser-mode application might go through the file server, which wouldmake a Symbian OS kernel request, which would require device I/O,which would make use of the nanokernel.
A phone call might initiatefunctions in the RTOS, which would interact directly with the hardware.58KERNEL STRUCTUREAn application might simply cause arithmetic instructions to execute andmight not use any kernel functions at all.Note that we did not mention the extension portion of the kernelstructure. Extensions are device drivers that are loaded and executedwhen a phone boots up.
They interact with the kernel and can causekernel-mode operation. However, they represent layers in the kernelthat extend functionality, but do not directly interact with user-modeapplications. For example, the ASSP layer is an extension.3.5 SummaryThis chapter has been about how kernels are structured and how thevarious parts of a kernel interact with each other and with user-modecode.
We began with a general look at kernel components from a layeredperspective and the perspective of active and passive components. Wethen defined system calls and interrupts in relation to the kernel. Wecompleted the chapter by taking a fresh and complete look at theSymbian OS kernel structure, from the hardware to user-mode threads.In the next chapter, we begin to look at memory models and howmemory must be organized to use it effectively.Exercises1.Consider the following services (seen in Chapter 2) and classify themas to where their implementation would take place in the kernelstructure.a.
Opening and closing filesb.Writing to a registerc. Reading a memory celld.Receiving a text messagee. Playing a sound bite.2.Reconsider the following question from Chapter 2 and pinpoint theplace these operations should happen in the kernel structure. Whichof the following operations should be done in the kernel as privilegedmode?EXERCISES59a. Reading and writing filesb.Sending a text messagec. Taking a picture with the camerad.Notifying a program about data receivede. Switching processes on the CPUf.Reading from a memory cell.3.Consider a software timer that would be used by software as a ‘wakeup device’ or an alarm that would send a software interrupt whenthe timer goes off.
Place a priority on the timer interrupt. Name someevents that are more important than a timer event. Name some eventsthat are not as important.4.Should a timer be a real-time or a system-time object? In other words,should it be implemented by the RTOS or by the system kernel?Explain your answer.5.Consider the phases of interrupt implementation (Section 3.3).
Wementioned that ISR execution is pre-emptible. Should the other stepsbe pre-emptible? Give reasons for your answer.6.Consider again the diagram in Figure 3.2. Why is the nanokernel ontop of the Symbian OS kernel, which is on top of the memory model?According to Figure 3.1, the nanokernel is the innermost layer. Canyou describe why the diagram in Figure 3.2 is accurate?7.Symbian OS is an extensible operating system. If someone wanted to,they could write code that would run completely in kernel mode foreach of its operations. Explain how this could happen – especiallywhen we described system calls as built into the operating system.8.Describe why you might want to replace passive components of anoperating system with components that you could write.