next up previous contents
Next: Programming Language Up: Implementation Previous: Implementation

Subsections

Multiprocessing Environment

  Simultaneous client-accesses to the News Cache must be possible. Hence, we must spawn a new process or at least a new thread for each client. Since all these processes (or threads) access common resources like the newsgroup database mutual exclusion has to be assured.

Processes

Processes are available on all multiprocessing platforms in a similar manner. However, processes have the disadvantage that a task switch between two processes is more expensive than a context switch between two threads.

Processes do not share their data segment. Hence data that could be shared in theory would be allocated twice. As another disadvantage processes usually do not share their data structures.

One possibility to provide shared memory between different processes is to request a chunk of shared memory explicitly. The shared memory should be requested in big chunks, since the number of shared memory segments is limited on many operating systems. In addition a large number of smaller chunks reduces the performance of the whole system.

On most modern operating systems like Unix or Windows NT a system call to map the contents of a file into a process's memory space is available. Many different processes may map the contents of the same file into their memory space. In this case, modifications to the file can be shared by all processes. This method is similar to requesting shared memory, but has several advantages. Most importantly all data are implicitly stored on non volatile memory and need not be written onto a file explicitly. In addition it reduces the process's memory requirement.

In both situations mechanisms have to be provided to ensure mutual exclusion. Usually, semaphores are used to ensure mutual exclusion on shared memory and file locking is used for the file-mapping approach.

We think the best solution for the News Cache is the use of a memory-mapped file, because the data must be stored onto a file, too.

Threads

Threads have the advantage that a context switch between threads is cheaper than a task switch and that they can share their variables without explicit allocation of shared memory.

Threads allow a better exploitation of parallelism, because the inter process communication is cheaper in terms of resources needed, and data sharing can be performed on a finer scale. However, special care has to be taken for the exploitation of this extra parallelism, otherwise the performance of the whole system can decrease.

Unfortunately, threads are not supported by all operating systems. Although a portable Posix [Pro97] compliant thread library exists for many operating systems, this library is only installed on very few systems. Also the libraries that come along with the operating systems differ, which complicates the system's independent implementation.


next up previous contents
Next: Programming Language Up: Implementation Previous: Implementation
gschwind@infosys.tuwien.ac.at