O'Reilly logo

Shared Source CLI Essentials by Ted Neward, Geoff Shilling, David Stutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Processes and Threads

The SSCLI provides a rich set of threading features to the developer, and because of this, it makes some heavy demands on the operating system beneath its PAL. The PAL specification requires support for:

  • Process creation

  • Process termination

  • Process exit code access

  • Interprocess memory access

  • Interprocess communication using memory mapping

  • Interprocess communication using events

  • Inheritance of standard handles through process creation

Between the C runtime, POSIX system calls, and pthreads (the POSIX threads package), the Unix PAL has most of what it needs to implement these features on Mac OS X and FreeBSD.

PAL Processes

The model for process isolation in the PAL is simple: each process created is mapped to an underlying operating system process. The first process is created by a program that wishes to host the PAL, which can then create additional subordinate processes by calling CreateProcess . (CreateProcess, as with many Win32 APIs, comes in two related flavors: CreateProcessA for use with ANSI string arguments and CreateProcessW for use with Unicode string arguments.) The API ensures that the executable file being used is either a valid CLI PE file or else a native executable. If it is a CLI executable, the name of the application launcher, clix, is prepended to the command line. From there, the Unix PAL uses fork to create the new process and execve to launch it, inheriting standard filehandles if requested.

Information about processes is divided between two important ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required