LinuxUser & Developer
amously interested in sel replicating automata,and with data or the description o possibleospring, and code or process, the physicalmachine itsel, on an equal ooting, hisarchitecture readily embeds sel-reproduction.It’s a necessarily viral architecture with replicationabounding.
The poLiTics of process
Yet, reducing this deadly crash potential to asymptom o a attening o privilege meansintroducing hierarchy into the equation.Segmentation, segregation, and a division intokernel and user modes mark splits which render the process political at a number o levels. Thedivision between so called real and protectedmode embedded within all x86 compatible CPUsexposes the degree o control which is aordedhardware vendors. The hierarchy o user andkernel mode heralds a rough division betweenuser, or rather application programmer, andkernel coder. The kernel hacker dictates how lessenlightened app monkeys code GUIs which usersare then orced to adapt to. It’s a loose chain o command, which, travelling up rom hardware,through the layers o abstraction within sotware,arrives at the interace; a return journey whichprocess undertakes and which can well betraced. At the same time a similar route isventured at boot time; a trip rom bare hardware, through BIOS inreal mode, straight to protected mode as the OS bootstraps thecommandline interace into existence. Already, there’s a good deal on oer here, material ripe or analysisand using a ree sotware OS implementation, with ready source codeaccess under grep and riends, and with open tools such as the GNUdebugger GDB and strace system call tracing tool we can readily askessential questions, interrogating the political nature o computationalprocess. With /usr/src/linux as our starting point we can well illuminatecomputation through analysis o what happens at the micro and macrolevels; the magical transormation rom code to action which processmarks in a journey rom user to kernel space and back again, passingthrough the analogue barrier o noise at the electrical level o the CPU. With reerence to the parallel journey at boot time into protectedmode, we can grep through code under /usr/src/linux/arch/i386/bootto fnd exactly when the transition is made.
fork and die
Yet beore we’re ready to walk the code, or strace the process, anenlightening aair both or debugging and perormance tuning, it’sworth asking what process encompasses under computation, andwhat exactly constitutes a process within the specifc terms o a Unix-like OS. In the frst instance the transition rom code to execution, rom command to result, marks the process. Many writers have alsodescribed computational process with reerence to magic; the processas an invisible spirit conjured up by a sorcerer’s spells, or programs, yet still obtaining quite physical eects in the real world.Process is the only entry point into crash and the virus. At the sametime computers simulate and model processes rom the real world,and the relation between the two marks process as interace. Drillingdown to a more specifc context, and sticking with the commandline,process and program, or executable become separated. Under theterms o a Unix operating system, a program is run, that is to sayexecuted, within a process. Process is that which renders theexecutable, a bland ELF (Executable and Linking Format) fle withadditional libraries, runnable, passing code to the kernel by way o the ubiquitous interace o the system call which unctions as aspeakeasy style hole in the wall between user and kernel spaces.The process keeps track o the state o the running program. GNU/Linux users will no doubt be amiliar with the common ps commandwhich details a vast array o such inormation regarding processes. Allthat runs, and in some instances, as we’ll see in the case o zombies,which doesn’t run, is process, assigned a unique ID by the kernel. Buthow do such magical processes come into being, i we need a processto execute and manage code, and where does this process come rom? In Unix there is but one parent process, init, whose invocationwe can again trace to source outlining the boot code. Init is theancestor, or parent, o all processes, which are known as childprocesses. Init has a process identifer, a PID, o one. It’s our originalunit, rom which the shell is spawned. And the shell, rom which weissue commands, can urther deliver ospring which are themselvescapable o birthing processes. Such a spawning is known as orking,under which the existing process is duplicated with the childreceiving new parameters. The parent is responsible or the childprocess, hence the common Unix geek joke that “children are orkedby their parents who then wait or them to die...”Process creation and termination can be readily tracked down to ork.c and exit.c under the main kernel directory o /usr/src/linuxwhich provide clues to process management under GNU Linux. Theattributes o a process are crammed into a data structure called task_struct which allows or scheduling (see sched.c) and memorymanagement, enabling switching between processes without losingtheir state and context. Ater all it’s worth remembering that onemain role o a multitasking kernel is to control when the process hasaccess to the bare metal o the CPU. The kernel dictates thephysicality o execution, acting as key interace between code and thereal world. Without OS the executable is just junked data. Yet orking doesn’t quite take us the ull distance into the land o execution. Forking means that we have two copies o the sameprogram running. One o them usually executesthe binary making use o one o the exec() amilyo system calls which will replace the processwith another process. The exec() system calllocates the binary image o the executable, loadsit, and runs it, taking care o binary ormats andshared libraries.
The great amily tree o init can be examined onany live system by issuing the simple pstreecommand. On the author’s system we see init onthe ar let, with multiple descendants, such as thevarious system daemons which kick o at boottime. We can ollow the branch which marks our current process rom init, through login, Bash,startx, xinit, X into window manager Ion andthence rom xterm, and Bash into GNU Emacs. Another view o process is oered using thestrace command, making use o the ptrace
LinuxUser & Developer
Under GDB, thesuperbly intricate GNUdebugger, we canreadily issuebreakpoints and thuspull apart frozen code,viewing process from amyriad of embeddedangles
Under a proprietary OS thesystem is quite obviouslyobscured, conditioning theuser under a supposedlynatural interace; theprogrammer as god hidingbehind veiled error messagesmasking a very human ailure.The error message isconsidered as a natural sign, atrue symptom with some linkto an underlying natural cause. A psychosomatic responseissued by a body o code, acomponentless, purely binarybody. It appears to the casualuser as set in stone, flled withdark intent as it seemingly hails rom the other side o crashland. Ater all how can acrashing system report its owndeath? Yet, its arbitrary nature iswell belied by ree sotwarewith apparent code, searchableas to exact message and cause.The decisions o a nowhumbled programmer or collective are exposedalongside colloquialcomments. Rather thanviewing a message as totallymeaningul, as imbued with anoracular aura, ree sotwarereveals the truly error proneand noisy realm o analoguecode. Coders write error messages, not computers, andprogrammers can always makemistakes. Error codes needmake little sense, with lazygrasp-all cases embracing allmanner o ills under the samebanal message.Exposure is a key concept or both ree sotware and whatcould be reerred to as codeart, rendering a geologicalaesthetic, which may becontrasted with the art o thelandscape, along the rich seamo executable or runnablestrata meeting the readableand writable. Technique andtechnology are revealedneither as ends in themselvesnor as tools or the productiono stock works, but rather as anexplosive and extremelygratiying sel exposure o ideas. In the words o Wildeanprogrammer, Alan J. Perlis,preacing one o the greatestcomputer science works,Structure and Interpretation o Computer Programs, “Thesource o the exhilarationassociated with computer programming is the continualunolding within the mind andon the computer o mechanisms expressed asprograms and the explosion o perception they generate.”Computers model process,execution is process and reesotware exposes all theprocesses, social, cultural,economic and otherwise whichwrap up code.
Reducing this deadly crash potential to a symptom of a attening of privilege means introducing hierarchy into the equation
The ps command,with an array ofcommand lineoptions, and relatedpstree tool, providefor yet another viewof running process,here showing thehierarchy of parentand child process on aworking system