Protothreads
Encyclopedia
In computer science
, a protothread is a low-overhead mechanism for concurrent programming.
Protothreads function as stackless
, lightweight threads
providing a blocking context cheaply using minimal memory per protothread (on the order of single bytes).
Protothreads are non-preemptable
. Therefore, a context switch
can only take place on blocking operations
. Protothreads are also stackless, which means global variable
s are needed for preserving variables across context switches.
The protothread concept was developed by Adam Dunkels
and Oliver Schmidt.
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...
, a protothread is a low-overhead mechanism for concurrent programming.
Protothreads function as stackless
Call stack
In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack"...
, lightweight threads
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
providing a blocking context cheaply using minimal memory per protothread (on the order of single bytes).
Protothreads are non-preemptable
Preemption (computing)
In computing, preemption is the act of temporarily interrupting a task being carried out by a computer system, without requiring its cooperation, and with the intention of resuming the task at a later time. Such a change is known as a context switch...
. Therefore, a context switch
Context switch
A context switch is the computing process of storing and restoring the state of a CPU so that execution can be resumed from the same point at a later time. This enables multiple processes to share a single CPU. The context switch is an essential feature of a multitasking operating system...
can only take place on blocking operations
Blocking (computing)
Blocking occurs when a subroutine does not return until it either completes its task or fails with an error or exception. A process that is blocked is one that waits for some event, such as a resource becoming available or the completion of an I/O operation.In a multitasking computer system,...
. Protothreads are also stackless, which means global variable
Global variable
In computer programming, a global variable is a variable that is accessible in every scope . Interaction mechanisms with global variables are called global environment mechanisms...
s are needed for preserving variables across context switches.
The protothread concept was developed by Adam Dunkels
Adam Dunkels
Adam Dunkels, Ph.D., is a Swedish software engineer, researcher and co-founder of the Networked Embedded Systems Group at the Swedish Institute of Computer Science in Kista, Sweden. His research is mainly focused on networking technology and distributed communication for small embedded devices and...
and Oliver Schmidt.
External links
- Protothread library in C used by ContikiContikiContiki is a small, open source, highly portable multitasking computer operating system developed for use on a number of memory-constrained networked systems ranging from 8-bit computers to embedded systems on microcontrollers, including sensor network motes...
- Using Protothreads for Sensor Node Programming A PDF with some in-depth discussion about the use of Protothreads
- Protothread library requiring GCCGNU Compiler CollectionThe GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
, includes a thread schedulerScheduling (computing)In computer science, a scheduling is the method by which threads, processes or data flows are given access to system resources . This is usually done to load balance a system effectively or achieve a target quality of service...
modeled on the UNIX kernel (a simplified form of POSIXPOSIX ThreadsPOSIX Threads, usually referred to as Pthreads, is a POSIX standard for threads. The standard, POSIX.1c, Threads extensions , defines an API for creating and manipulating threads....
condition variables) - Eigenclass performed a comparison of protothreads against POSIX threads, and found a 400x improvement in speed http://eigenclass.org/hiki/threadring-with-protothreads
- C++ Protothread
- Symbian C++ Protothread Implementation
- Protothreads: Threads en C sin sistema operativo ni memoria RAM Publicación de Arte en 8 bits sobre los protothreads