Table Of Contents
  • Pthreads
  • Client/server programming
  • Processes and jobs
  • System I/O
  • Signals and traps

Pthreads

Short for POSIX Threads, Pthreads are execution models incorporated in a programming language that allows applications to control overlapping flows of work. Flows of work are commonly referred to as threads and creating and controlling these flows requires calling the Pthreads. Threads exist within UNIX process resources and can be scheduled to run independently mostly because they make copies of the essential resources that allow them to coexist with other resources as an executable code. To accomplish an independent flow of control, a Pthread has to maintain its own registers, stack pointer, blocked and pending signals, scheduling properties, and thread-specific data.

Client/server programming

Client/server programming is a computing architecture whereby the information users (clients) are segregated from information providers (servers). There are at least two computers involved; one that requests for services and another one that evaluates and analyzes those requests. All client/server networks include the following:
  • Request: Sent over the network to trigger an action and/or get a response.
  • Broadcasting: Sending a given set of data or commands to every client that is connected to the network.
  • Connection: A link between two computers or devices where data flows in both directions.
  • Socket: One end of a connection with a unique identification number. It is provided by an operating system like UNIX.
  • Ports: Each socket has an input port from which data is read and an output port to which data is written.
  • Callback: A procedure called in response to a request or event.

Processes and jobs

A process is an instance of an active or running application. When you run an application on UNIX operating system, a special environment is created for the application, containing everything the system needs to execute the application as if there is no other program running on the system. Every time a command is issued in UNIX, the command creates or initiates a new process. Jobs are a single process group managed by an operating system. UNIX tracks processes through a process ID and every process have a unique five-digit identification number referred to as pid. At some point, the process IDs start to repeat themselves because all the numbers are used up, hence the next ID starts or rolls over. However, no two process IDs exist at the same time because UNIX uses these IDs to track a process, and having two IDs running concurrently could result in undesirable results.

System I/O

In computer systems, an I/O (or Input/Output) is the means of communication between a computer or any other information processing system and the outside world, perhaps another information processing system or humans. There are two types of Input/Output systems in UNIX; character devices and bock devices. Character devices include printers and terminals that don’t use block buffer cache. Examples include /dev/mem that connects to physical memory. Block devices, on the other hand, include devices that store blocks of a specified size like disk memories and are usually called through the file systems. Some are also stored as special files and examples include /dev/hde1.

Signals and traps

Signals are software interrupts directed to an application to show that an important function or event has taken place. An event can be of many different natures; it can be a user request or even an unauthorized memory access error. Some signals like the interrupt signal show that the application has been prompted to perform an operation that is not in the standard flow of control. Traps are algorithms used to ignore signals or clean up temporary files. When you press the Break key or ctrl+C during the execution of a shell application, in most instances, the application is aborted immediately, bringing back your command prompt. This may not always yield desirable results. For example, plenty of temporary files may be left behind that may need cleaning up. Using traps helps clean up these files quickly, enabling the proper and efficient running of programs.