processes. 1/19/2014 2 processes modern systems can have many operations occurring at the same time....

22
Processes

Upload: lauren-cooke

Post on 26-Mar-2015

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

Processes

Page 2: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/232

Processes

Modern systems can have many operations occurring at the same time. Most applications require one or more processes to be running. Large systems can have thousands. Each process takes time to load and unload, and consumes resources like CPU time, memory, file handles, and disk access. The organization and functioning of processes is a major topic in distributed computing.

Page 3: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/233

Process

A process can be considered a program in execution. Computers time share processes, alternating executing them in time slices managed by interrupts. The computer needs to maintain a process table to manage active processes. Each process requires entries for CPU register values, memory maps, open files, accounting information, privileges and other information so that when the next time slice is available, the process can pick up where it left off.

Page 4: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/234

Process Overhead

One major concern in corporate computing is throughput or efficiency. Large volumes of data will require more staff, more real estate, and more equipment on slower systems. For most large companies, the differences in efficiency can amount to many millions of dollars. One major concern in performance is process overhead, particularly starting up and shutting down processes and allocating resources to them.

Page 5: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/235

Shared Processes

One approach to efficiency is to keep a number of processes open all the time to share among multiple users, to avoid start-up, shut-down and other overhead activities. Transaction processing monitors are software applications specialized for this. They can also increase the number of processes to run small ones that demand few resources and reduce the number for large processes needing many resources.

Page 6: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/236

Threads Threads can be used to maximize throughput. A

single process can be multi-threaded, so that several tasks can occur in parallel. A single threaded process may block for an activity such as disk access, which may cause the process to miss an event such as a mouse click. Threads are similar to processes, also using time slices, but require less information, less data swapping, and less protection from interference because they are shared by a single process which tracks the common requirements.

Page 7: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/237

Advantages A multithreaded application can handle parallel

tasks. For example, a word processor can use one thread for editing, another for spell checking, one to generate an index and another to display the text layout on the screen.

Frequently, switching threads requires only loading the CPU registers instead of the whole process context.

Threads can also increase throughput in multiprocessor systems.

Page 8: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/238

Thread Safety

The biggest disadvantage of threads is that because they have less protection from interference than processes, they require careful design and intelligent programming. The programmer must understand the pitfalls so they can be avoided. Programming practices for multithreading refer to this concern as thread safety.

Page 9: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/239

User Level and Lightweight Processes

Threads can be carried out within the program itself. However, an I/O activity could then block all threads in that process. An alternative is to have the system handle the threads. But that requires system calls to switch threads, and requires almost as much overhead as a process. A hybrid form of user and system threads is called Lightweight Processes, or LWP. LWPs can be designed to blend the advantages of system and user threads.

Page 10: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2310

Hybrid Solution One or more heavyweight process can each have from

one to several lightweight processes and a user level thread package, with facilities for scheduling, creating, destroying and synchronizing threads. All of the threads are created at the user level, and assigned to a LWP. When a thread is blocked, the scheduling facility searches for a thread that can execute. Multiple other LWPs can be looking for executable threads at the same time. Since the tread scheduling is in user space, system calls can be made without stopping everything.

Page 11: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2311

Threads in Distributed Systems

The ability to make system calls without suspending all other processes is important in distributed systems, because it allows multiple logical connections at the same time. Remote communications have high latencies. Think of the several seconds you have waited before getting a 404 error on the Internet. Computer functionality would be greatly reduced if the whole system had to wait for a network operation to complete, and only one could occur at a time.

Page 12: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2312

Multithreaded Servers

The main benefit of multithreaded network communications is on the server side, because a single server may simultaneously serve many clients.

Frequently a concurrent server will start a new thread to handle each client, as in the algorithm on the next slide.

Page 13: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2313

UDP Concurrent Server AlgorithmComer and Stevens, Algorithm 8.3

Master: Create a socket and bind to the well known address

for the service offered. Leave socket unconnected Repeatedly call recvfrom to get requests and create a

new slave thread Slave:

Receive request and access to socket Form reply and send to client with sendto Exit

Page 14: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2314

Client Multithreading

An important use of multithreading on the client side is GUI (Graphical User Interfaces) and OOUI (Object Oriented User Interfaces. Multithreading allows these to separate user processing from display functions and event handling.

While there is a section on GUI and OOUI in the operating system lecture, let us examine one GUI, the X-Windows System.

Page 15: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2315

NJIT X-Windows example Students can access the AFS system over telnet,

but only have command line access. They cannot use the AFS graphical editors or IDEs like NetBeans unless they install an X-Windows emulator on their Windows computer to handle the placement of objects on the screen. Note that to access X-Windows from off campus, you must also install a Virtual Private Network (VPN). Unfortunately, all this software combines with network processing to slow down your operations.

Page 16: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2316

Code Migration

As I have already stressed, one of the most important considerations in commercial Information Technology is efficiency and throughput. NOTE: A solid understanding of this issue is a wonderful asset in a job interview!

One way to get more processing for the same amount of money is to move processing from heavily loaded systems to lightly loaded systems. This is one aspect of code migration.

Page 17: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2317

Fat Client and Fat Server

Code processing can take place anywhere on a system. If most of the processing takes place on the server, it is called a Fat Server, while the opposite is a Fat Client. Thus, if a server cannot handle all the load that is thrown at it, an alternative to buying another expensive server is to move some of the more intensive computation to the clients by migrating some of the code. In addition to increasing performance, this can also increase flexibility.

Page 18: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2318

Efficient Migration

If code can be moved easily between machines, then it is possible to dynamically configure distributed systems. This is a key idea behind distributed object systems such as CORBA, where the application environment can be very dynamic, involving many objects, with new objects able to be added at any time and others moved to faster machines or ones with spare capacity.

Page 19: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2319

Java Applet

Another example of code migration is the Java Applet, which can be fetched from a server and execute on a client. The applet can also access the server for functionality that is not sent to the client.

Page 20: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2320

Weak Mobility

A bare minimum for code migration is the ability to transfer only the code segment and some initialization data. This is called weak mobility. This is simple to accomplish, and only requires that the code be portable so that the client can execute it.

Page 21: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2321

Strong Mobility

If you also download the execution segment, then you have strong mobility. A key distinction is that with strong mobility a running process can be stopped, moved to another machine, and resume where it left off. Strong mobility is more difficult to implement.

Page 22: Processes. 1/19/2014 2 Processes Modern systems can have many operations occurring at the same time. Most applications require one or more processes to

04/10/2322

Mobility Initiation

Another distinction is whether the mobility is sender-initiated or receiver-initiated. Sender initiation examples are uploading programs to a computer server, or initiating a search on a remote computer.

Receiver initiated mobility is when the target machine requests the code, such as downloading a Java Applet.