702 Part VI . Programming in Linux Races (Cpanel web hosting)

702 Part VI . Programming in Linux Races occur when the result of a computation depends on the order in which two events occur. Say, for example, that two processes are accessing a file. The first process writes data to the file, and the second process reads data from the file to calculate and display a summary value. If the reader process reads the file after the writer completes, the reader calculates and returns the correct value. If the reader process reads the file before the writer completes, the reader will calculate and return an incorrect summary value. The likelihood of deadlocks, livelocks, or races occurring increases dramatically on multitasking (and multiuser) systems because the number of processes that are potentially competing for access to a finite number of resources is greater. Good design, careful analysis, and the judicious use of locks, semaphores, and other mutual exclusion (or mutex) mechanisms, which mediate access to shared resources, can prevent or reduce their occurrence. Multiuser by Design Linux is multiuser by design, an element of the Linux development model that has far-reaching consequences for developers. A program cannot assume, for example, that it has sole access to any resource such as a file, memory, peripheral devices, or CPU time; multiple programs might be attempting to print simultaneously or trying to allocate memory. Similarly, a program cannot be written with the assumption that only one copy of the program is running at a time. So, if you are writing a program that creates temporary working files in /tmp, you need to ensure sure that the temporary files created by Bubba s copy of the program are distinct from the temporary files created by Mary Beth s instance of the program, or hilarity will ensue (if not hilarity, at least confusion and consternation). Another common need is for programs to honor per-user configurations. At startup time, a program might apply reasonable global defaults and then read a user s configuration file to apply, say, a custom color scheme. There are also a number of per-user settings, such as environment variables, that programs need to know how to accommodate. For example, the MAIL environment variable identifies where the user s mail spool file is kept; the VISUAL environment variable defines the user s preferred full screen editor (which all true Linux users know is vi); the PRINTER environment variable stores the name of the user s default printer; and, of course, HOME identifies the user s home directory. In a system such as Linux that is pervasively multiuser, programs and programmers must always take into account that most resources a program might want to use are usually shared resources and that most real-world usage scenarios (more formally known as use cases) assume that multiple instances of the program are running at the same time. Interprocess Communication Interprocess communication (IPC) enables programs to share data and resources with a minimum amount of overhead and is used extensively on all Linux systems. It is especially common with daemons and server process that spawn child processes to handle client connections. IPC comes in three varieties:, shared memory,
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Leave a Reply