1.1 Threads

A thread is a stream of control that can execute its instructions independently. In the past, threads have sometimes inaccurately been referred to as NetWare processes. Process is more properly a concept used in UNIX* or Windows* NT. For operating systems in which the kernel does not support threads, a process is the unit of execution. In contrast, for a multithreaded system in which the kernel supports threads, a thread-rather than a process-is the unit of execution.

The NetWare OS allows NLM™ applications to establish multiple threads, each representing a single path of execution. An NLM usually contains at least one thread to accommodate the main function. (This is not true if the NLM is a library, such as CLIB.NLM.)

Two or more threads can be running concurrently-simultaneously in the midst of code execution-although only one thread can have control of the CPU at any given time. Concurrent threads can be executing the same code or different code. In a multiprocessing evironment, two or more threads can also be running parallel-that is, simultaneously running on different processors. Parallel threads are of course also running concurrently.

Historically, the NetWare OS has been a nonpreemptive ("good guy") scheduling environment. (NLMs written for NetWare 5.x and 6.x can be marked preemtable, as explained below.) When a thread gains control of the CPU, the thread remains in control until it has run to the end of its execution or until it calls a function that ’blocks’-that is, relinquishes control of the CPU. (Blocking functions are identified in the function reference manuals.)

No other thread can interfere with an active thread, regardless of priority. Only a hardware interrupt can temporarily interrupt a currently running thread.

1.1.1 Thread Context

In the NetWare OS, many of the threads run in groups that are organized such that all threads in a group share data that is global to the group. The characteristics of that global data is collective called context. Context is one of the more important concepts to understand in programming to NetWare. For more information on context, see Section 1.4, Context and Thread Groups and Section 1.5, NetWare Global Data below.

For developers of driver, stack, and other lower-level code, please refer to Section 1.9, Context and Development of Drivers, Stacks, etc.