Linux Device Drivers

Linux Device Drivers

Character drivers
IO & Memory
Linux Kernel
Process Management
Process Address space

Linux Scheduler
Memory Management
System Calls
Kernel Synchronization
Linux Inter Process Communications

Serial Ports
Parallel Ports
Introduction to Hardware
Linux Timers
DMA in Linux
Linux Threads
Linux Thread Synchronization

Linux Multi Threading
Debugging in Linux
GDB GNU Debugger
KDB Kernel Debugger
KGDB Kernel GNU Debugger
Example Ethernet Driver

Multithreading Model

Multithreading Model


Support for threads may be provided either at the user level, for user threads or by kernel, for kernel threads.

User threads are supported above the kernel and are managed without kernel support, whereas kernel threads are supported and managed by operating system.


All OS –windows XP, Linux, Mac OS X, Solaris and True64 Unix support kernel threads.


Many-to-One Model


The many-to-one model maps many user-level threads to one kernel thread. Thread management is done by thread library in user space, so it is efficient. But the entire process will block if a thread makes a blocking system call. Also, only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multiprocessors.

Example: Green Threads for Solaris, GNU Portable Threads.



Many-to-one model



One-to-One Model


The one-to-one model maps each user thread to a kernel thread. It provides more concurrency than the many-to-one model by allowing another thread to run when a thread makes a blocking system call. It also allows multiple threads to run in parallel on multiprocessors.

The drawback in this model is that creating a user thread requires creating the corresponding kernel thread, causing overhead.


Linux along with family of Windows OS implement this model.


One-to-one model



Many-to-Many Model


The many-to-many model multiplexes many user level threads to a smaller or equal number of kernel threads. Developers can create as many user threads as necessary and the corresponding kernel threads can run in parallel on a multiprocessor. Also when a thread performs a blocking system call, the kernel can schedule another thread for

execution. Kernel thread user thread



Many-to-many model



Thread Libraries


A thread library provides the programmer an API for creating and managing threads. There are two ways of implementing a thread library:


First approach is to provide a library entirely in user space with no kernel support.


The second approach is to implement a kernel-level library supported directly by the operating system.


Three main thread libraries are in use today:


1.     POSIX Pthreads

2.     Win32

3.     Java