Intermec ck1 Reference Guide
Appendix A —
µClinux System
296
CK1 SDK Programmer’s Reference Manual
The scheduler under the Linux kernel seeks for the process with the
highest priority in the queue of the run state processes. The real-time
processes are always executed first. This priority is ensured by giving the
normal process a priority of counter plus 1000. When the processes are
assigned with an equal priority, the kernel uses a round robin algorithm by
choosing the process nearest to the front of the queue. If the kernel notices
a process that runs on a higher priority than the executed one, the current
process must be suspended and the higher priority process is executed.
This is known as preemptive scheduling. When the kernel starts to execute
a different process, it saves the values corresponding to the current task in a
stack and restores the values of the next process to the CPU register and
continues the execution of that process. The saved values are stored in the
processes task_struct data structure.
highest priority in the queue of the run state processes. The real-time
processes are always executed first. This priority is ensured by giving the
normal process a priority of counter plus 1000. When the processes are
assigned with an equal priority, the kernel uses a round robin algorithm by
choosing the process nearest to the front of the queue. If the kernel notices
a process that runs on a higher priority than the executed one, the current
process must be suspended and the higher priority process is executed.
This is known as preemptive scheduling. When the kernel starts to execute
a different process, it saves the values corresponding to the current task in a
stack and restores the values of the next process to the CPU register and
continues the execution of that process. The saved values are stored in the
processes task_struct data structure.
All tough tasks are continuously interrupted as the Linux kernel switches
between different processes to share the system resources, the interrupts
still cannot happen at any time. Under Linux the interrupts can be
disabled by a process such as the system call. This method is called a
priority inversion, and it disables the case that the higher priority process
can take over the CPU at any time. This is also one major reason why
Linux is not a real-time operating system.
between different processes to share the system resources, the interrupts
still cannot happen at any time. Under Linux the interrupts can be
disabled by a process such as the system call. This method is called a
priority inversion, and it disables the case that the higher priority process
can take over the CPU at any time. This is also one major reason why
Linux is not a real-time operating system.
Reentrant Kernel
The Linux kernel is reentrant, meaning that several processes can be
executed, or at least block the kernel, at the same time. The Linux provides
this by introducing reentrant functions and a set of locking mechanisms to
prevent several processes from executing a non-reentrant function at the
same time. A reentrant kernel function is a function that can
simultaneously execute by several processes without fear of data
corruption. This is done by using only local variables or protecting the
data when global variables are used. It ensures that the function can be
interrupted and resumed at any time. The kernel also has methods of
protecting non-reentrant functions with disabling interrupts during critical
regions, using a spin lock to control access to data structures, or control
the access through semaphores.
executed, or at least block the kernel, at the same time. The Linux provides
this by introducing reentrant functions and a set of locking mechanisms to
prevent several processes from executing a non-reentrant function at the
same time. A reentrant kernel function is a function that can
simultaneously execute by several processes without fear of data
corruption. This is done by using only local variables or protecting the
data when global variables are used. It ensures that the function can be
interrupted and resumed at any time. The kernel also has methods of
protecting non-reentrant functions with disabling interrupts during critical
regions, using a spin lock to control access to data structures, or control
the access through semaphores.
For programmers, the reentrant kernel should be noted when writing
kernel modules. All the kernel code should be reentrant. For programmers,
this means that when writing the kernel-level code, the code needs to
handle more than one simultaneous access. Also the code needs to access
other shared data in such away that it does not corrupt the used data. A
hardware interrupt in the Linux kernel is also able to suspend the current
process even if it exists in a kernel mode. This capability significantly
increases the throughput of the device controller that issues the interrupt.
kernel modules. All the kernel code should be reentrant. For programmers,
this means that when writing the kernel-level code, the code needs to
handle more than one simultaneous access. Also the code needs to access
other shared data in such away that it does not corrupt the used data. A
hardware interrupt in the Linux kernel is also able to suspend the current
process even if it exists in a kernel mode. This capability significantly
increases the throughput of the device controller that issues the interrupt.
Interprocess Communication
Processes in Linux communicate with each other and with the kernel via a
mechanism called interprocess communication (IPC). It enables the
process to send and receive messages from other processes, share memory
mechanism called interprocess communication (IPC). It enables the
process to send and receive messages from other processes, share memory