* What is a task, thread, or process? * How are processes related to tasks and threads? * A scheduler only needs to deal with tCBs which share TCB information. ========================[ TASK, THREADS, PROCESSES ]========================= tasks (don't need IDs/or equiv to first thr_id) -- various memory regions & protection domains, kernel resources. 'The "Pebbles" kernel supports multiple independent tasks, each of which serves as a protection domain. A task’s resources include various memory regions and "invisible" kernel resources (such as a queue of task-exit notifications). Some versions of the kernel support file I/O, in which case file descriptors are task resources as well.' -- kspec.pdf threads (need IDs) -- register set (including %eip) and owner task. 'Execution proceeds by the kernel scheduling threads. Each thread represents an independently-schedulable register set; all memory references and all system calls issued by a thread represent accesses to resources defined and owned by the thread’s enclosing task. A task may contain multiple threads, in which case all have equal access to all task resources. A carefully designed set of cooperating library routines can leverage this feature to provide a simplified version of POSIX "pthreads."' -- kspec.pdf processes -- a task with either one thread (traditional process) or a task with multiple threads (multithreaded process.) 'A traditional (or heavyweight) process has a single thread of control. If a process has multiple threads of control, it can perform more than one task at a time.' -- Ch4, book. ========================[ VARIANTS OF THREADS ]========================= single-threaded process -- single thread of control. multi-threaded process -- multiple threads of control. (Shared code, data, files, individual registers, stack.) user threads -- supported above the kernel and are managed without kernel support. kernel threads -- supported and managed directly by the operating system. pure user threads (N:1) -- no change to OS, thread switch "just swaps registers." pure kernel threads (1:1) -- "Every thread is sacred." 'kernel-managed register set, kernel stack, requires 1 PCB => 1 TCB + NtCB, 1 K-stack => N k-stacks.' -- L07a.pdf 'OS knows thread/process ownership, memory regions shared and reference-counted.' -- L07a.pdf 'Pebbles provides kernel-scheduled threads.' -- thr_lib.pdf (1:1 threads) many-to-many threads (M:N) -- OS provides kernel threads, M user threads share N kernel threads. thread context (tCB) -- register set, user/kernel stack, private storage area. -- Ch4, book. * Primary data structures: * ETHREAD -- executive thread block. (pointer to parent task, code entrance point) * KTHREAD -- kernel thread block. (scheduling and synchronization information, kernel stack) * TEB -- thread environment block. (tid, user stack, thread-local storage) task context (TCB) -- various memory regions & protection domains. -- Ch3, book. * Memory-management information -- base and limit registers, page/segment tables. * Accounting information -- amount of CPU or real time used, not needed for us. * I/O status information -- list of I/O devices allocated to the process.'