Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption.

Similar presentations


Presentation on theme: "Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption."— Presentation transcript:

1 Unit - VI

2 Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption

3 Real Time Tasks : Soft Real Time Even if deadline is missed output is accepted. No catastrophic outcomes. Hard Real Time If deadline is missed output is of no use. Catastrophic outcomes. Has predictable latency Often associated with the physical event

4 Linux Scheduling : Real Time scheduling Requirement : A real-time process must be given absolute priority Unix and Linux are both designed for fairness in the process scheduling. All process should get required resources as they need to progress their execution as expected. This very design objective is a block to the requirement of real time process. Real Time Task has some real time attributes associated with it that scheduler use to identify it as highest priority process SCHED_OTHER, SCHED_FIFO, SCHED_RR

5 Latency :

6 Kernel Preemption : No kernel preemption till version 1.x No other process can be scheduled to run, until that process blocked (waits for something) or completed Kernel preemption allows one process to pre-empt a process running a kernel code (running in kernel space)

7 Kernel Preemption :

8 Challenges : Originally Linux kernel is designed under a non-preemptable model Later kernel patches are incorporated for checking strategic locations where preemption can be allowed. These points are the only safe point to allow preemption Drawbacks : Code for preemption checks were all around the kernel at strategic locations known to be safe for preemption. Preemption was enabled only at these known-safe points.

9 Challenges : Identify the places in the kernel that must be protected from preemption Critical section in the kernel where preemption is not allowed

10 Kernel Preemption: RT Approach Real time system requires further minimization of latency in Linux kernel, and needs the following improvements with this respect. The kernel should be fully preemptable anywhere. Critical sections or other more specific section should be the only points where preemption is disabled. Linux do not have support for hard real time in its mainline kernel source. Few hard real time system patches must be applied to use it in hard real time systems The patch enables the “Complete Preemption”

11 Preemption Model Options PREEMPT_NONE: It means no forced preemption. Average performance in terms of latency is good but long delays in some occasions are possible. Best suited for applications for which overall throughput is the top design criterion. PREEMPT_VOLUNTARY: The first stage of reducing the latency. Preemption identifiers or preemption point are places at certain strategic kernel source code location. It reduces latency up to some level. PREEMPT_DESKTOP: This model allows preemption anywhere in the kernel exception at critical section. Soft real time systems use this model. Useful for soft real-time applications PREEMPT_RT: With this mode enabled, kernel can be pre-empted anywhere except the part of source code which is protected by preempt_disable().

12 Preemption Model

13

14 Porting Linux : The term OS porting means to modify or customize an OS, which is running on particular hardware architecture, in such a way that it can run on another particular kind of architecture when loaded into one. if we required loading the Linux OS into an embedded device, we must do something that will enable the OS running on x86 based hardware to run on ARM based hardware, and we call it Linux Porting.

15 Linux Kernel Construction : Building the kernel for target Configuration Compilation Top level directory... / representation of root directory Next level subdirectories contains source code, config files, makefiles... / drivers: peripherals, USB, Bluetooth etc.... / archarch related source codes (20 processors)... /ipc,... / documentation, etc

16 Linux Kernel Construction : Kernel Root Directory Arch Directory :... / arch

17 Linux Kernel Construction : Compiling the kernel Kernel Build Files Configure for specific architecture Compile to produce Kernel binary file System.mapkernel debugging Vmlinuxarch specific kernel binary image (ELF format) Kernel makefiles Useful for selective compilation make

18 Linux Kernel Construction : Kernel configuration and compilation Configuration : Type of Target hardware + required features Cross Compilation : ARCH and CROSS_COMPILE make ARCH= CROSS_COMPILE= Prepares kernel for arm architecture Eg : make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi Creates kernel image in... / arch/ / boot Kernel images : vmlinux, uImage, bzImage etc

19 Embedded Android : Bootloader Kernel Init Zygote System Server Activity Manager Launcher (Home)

20 Bootloader : Loads on CPU start Located at a fixed address Initializes RAM Puts basic hardware in a quiescent state Loads the kernel and RAM disk Jump to Kernel Image

21 Kernel : Early startup code is very hardware dependent Initializes environment for the running of C code Jumps to the architecture-independent start_kernel() function. Initializes high-level kernel subsystems Mounts root filesystem Starts the init process

22 Android Init : Open, parses, and runs /init.rc Create mountpoints and mount filesystems Set up filesystem permissions Set OOM adjustments properties Start daemons: adbd servicemanager (binder context manager) netd vold app_process -Xzygote (Zygote)

23 Zygote : Daemon that launches apps. app_process command to start Zygote by the Android runtime app_process –X Zygote Active only when a new app needs to be launched For faster app launch Preloads all required java classes and other resources Then it listens for connections on its socket On app launch request forks itself “Copy On Write” mechanism Only one copy of the system classes and the resources is ever loaded in RAM as no child updates these system resources.

24 System Server : First app created by Zygote Initialize services and register to Service Manager Services hosted by System Server Activity Manager Power Manager Headset Widget Notification Manager, etc. Activity Manager, will end its initialization by sending an intent of type Intent.CATEGORY_HOME Starts the Launcher App that displays home screen

25 Android Startup :


Download ppt "Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption."

Similar presentations


Ads by Google