What is multitasking?
Multitasking means running several processes (or tasks) in parallel.
This is a more general method than background timer routines.
What is multithreading?
What is sequential hardware?
What is the task definition?
Task, Process, Thread
* Similar to function/ procedure; no parameters, no return value
* Often contains (endless) loop
* Can read its own Task-ID
* Can terminate itself or others
What is scheduling?
Scheduler transfers control between tasks using time slices
What is he task model?
Refer to slides for diagrams
What is Pthreads?
====
▪ POSIX Threads = Pthreads
▪ A thread is best described as a “procedure that runs independently” from the main program.
▪ In Linux, a thread:
▪ Exists within a process and uses the process resources
▪ Has its own independent flow of control
▪ Terminates if the parent process terminates
▪ Because threads within the same process share resources:
▪ Changes made by one thread to shared system resources (such as closing a file) will be seen by all other threads.
▪ Two pointers having the same value point to the same data.
▪ Reading and writing to the same memory locations is possible, and therefore requires explicit synchronization by the programmer.
▪ Each thread requires a separate data stack
What are the Pthread functions
Refer to slides for examples and diagrams
What is synchronisation?
Problem:
* There is no way of telling when the time slice is up and the next task gets activated
* Task switch might come at a bad time
e.g. here in middle of printout
Solution:
* Task synchronization
– There are several methods, but here we only look at simple “mutual exclusive” locks = mutex
– Operations init, lock and unlock
What are the functions for Pthreads: Mutex Functions
What are the most important design issues for embedded systems?