1 / 57

Processes

Processes. Chapter 3. Introduction. A process is a program in execution For OS important issues are Management of processes Scheduling of processes In dist systems, issues such as Multithreading Process/code migration Software agents. Topics Covered. Threads Clients Servers

zenia
Download Presentation

Processes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Processes Chapter 3 Chapter 3  Processes 1

  2. Introduction • A process is a program in execution • For OS important issues are • Management of processes • Scheduling of processes • In dist systems, issues such as • Multithreading • Process/code migration • Software agents Chapter 3  Processes 2

  3. Topics Covered • Threads • Clients • Servers • Code Migration • Software Agents Chapter 3  Processes 3

  4. Threads • Processes (not threads): OSs makes sure • Processes do not affect each other, accidentally or intentionally (separation) • Processes not aware of each other (concurrency transparency) • Costly to set up independent processes • Switching between processes is costly • Must save state of current process • Must restore state of new process • Might also have to swap to disk Chapter 3  Processes 4

  5. Threads • Thread is like a (sub)process • But, OS does not provide concurrency transparency between threads • For example, don’t protect data from access by other threads within a process • Plusses? • Efficiency • Minuses? • More work for application developer Chapter 3  Processes 5

  6. Threading Example • Spreadsheet program • Change to one cell updates many cells • Interface is one thread, update another • Gives impression both are simultaneous • Even better in multiprocessor system • Other examples? • Word processor • Distributed examples? Chapter 3  Processes 6

  7. Interprocess Communication • If separate processes, 3 context switches • If same process, but separate threads, more efficient Chapter 3  Processes 7

  8. Thread Implementation • Two possible approaches • User-level threads  all in user space • Kernel-level threads  kernel is involved • User-level threads • Plus: cheap to create/destroy threads • Plus: thread context switch is cheap • Minus: Blocking system call will block all threads in process (e.g., blocking on I/O) • Kernel-level threads remove the “minus” • But thread context switching is more costly Chapter 3  Processes 8

  9. Lightweight Processes • User-level threads and… • Lightweight processes (LWPs) that act like kernel-level threads • LWPs take care of threads as needed • Plusses? • Thread stuff is efficient (user-level) • Blocking system call will not suspend all threads (provided enough LWPs) • Apps need not be aware of LWPs • LWPs can execute on different processors Chapter 3  Processes 9

  10. Threads and LWPs • A bunch of LWPs hang around • LWPs grab threads as needed Chapter 3  Processes 10

  11. Threads in Dist Systems • Advantage to threads in dist system • Can block without stalling entire process • Multithreaded clients • Conceal communication delays • For example, a Web browser • Multithreaded servers • More benefit on server side than client • Process incoming requests and do local things • Without threading, could implement this as a “big finite-state machine” (saving state, etc.) Chapter 3  Processes 11

  12. Multithreaded Servers • Multithreaded server • dispatcher/worker model Chapter 3  Processes 12

  13. Multithreaded Servers • Three ways to construct a server • Single thread  process stalls • Finite state machine  hard to program • Threads  totally awesome, dude • Threads rule! Chapter 3  Processes 13

  14. Threads: The Bottom Line • Consider RPC with blocking system call • Easy to program, but… • Inefficient without threads since… • No parallelism • W/O threads, finite state machine • Then obtain parallelism • But very painful to program • Threads provide • Sequential programming and parallel processes Chapter 3  Processes 14

  15. Clients • Client interacts with user and server • UI is sometimes simple • Cell phone • Sometimes UI is not-so-simple • X Window System Chapter 3  Processes 15

  16. X Window System • X Window System consists of • X kernel  low level interface for screen, mouse, etc. • Xlib  to access X kernel • Window manager  app that can manipulate screen • X protocol  allows for X kernel and X app to reside on different machines • X terminals  client using X protocol Chapter 3  Processes 16

  17. X Window System • Organization of X Window System Chapter 3  Processes 17

  18. Client-Side Transparency • Consider ATM and TV set-top box • For these, UI is small part of client side • Lots of processing on client side, lots of communication from client side • Client-side transparency is possible • Server side transparency harder to achieve (performance issues) • And not so important Chapter 3  Processes 18

  19. Client-Side Transparency • Access transparency • Client stub (middleware) • Location, migration, and relocation transparency • Naming • Replication transparency • One approach is on next slide Chapter 3  Processes 19

  20. Client-Side Transparency • Replication transparency • Client (stub) invokes object on all replicas • Collects responses and passes one result to client Chapter 3  Processes 20

  21. Client-Side Transparency • Failure transparency • Client middleware repeatedly attempt to connect to server • Client middleware tries another server • Client provides cached result • Concurrency/persistence transparency • ????? Chapter 3  Processes 21

  22. Servers • Server  a process implementing a service for a collection of clients • Server waits for incoming requests • Server services requests • Server can be iterative or concurrent • Iterative  handles request, response • Concurrent  passes request to another process/thread (fork a new process) Chapter 3  Processes 22

  23. Servers • Requests arrive at an endpoint • Port • How does client know endpoint? • Well-known • Some service to look it up • Superserver serves servers • Listens for a bunch of “servers” Chapter 3  Processes 23

  24. Client-to-Server Binding • Client-to-server binding using a daemon as in DCE • Client-to-server binding using a superserver as in UNIX Chapter 3  Processes 24

  25. Other Server Issues • How to interrupt server? • Break connection (common in Internet) • Out of band data • Stateless vs stateful • Stateless  no memory of clients and can change its state without telling clients • For example, a Web server (w/o cookies) • Stateful  remembers its clients • For example, file server must remember who has file at any given time Chapter 3  Processes 25

  26. Stateless vs Stateful • Stateless vs stateful server • What if server crashes… • Stateless? • No problem, just restart • Stateful? • Big problems… • Security of stateless vs stateful? Chapter 3  Processes 26

  27. Object Server • Server designed for dist objects • “a place where objects live” • Easy to change services on server • Read Section 3.3.2 Chapter 3  Processes 27

  28. Code Migration • Code migration  passing programs • Perhaps even while executing • Expensive, so why bother? • Consider process migration • Move a process to another machine • Move process from heavily loaded machine • A form of load balancing • When is it worthwhile? • Not easy to calculate in heterogeneous network • Minimizing communication may be good reason Chapter 3  Processes 28

  29. Code Migration • For example • Server manages a huge database • Spse client needs to access and process lots of data • May save bandwidth by shipping process to the server • Other examples (wrt performance)? Chapter 3  Processes 29

  30. Code Migration • Code migration might also increase flexibility • For example, it might be possible to dynamically configure the system • Dynamically download client software • No need to pre-install software • Other benefits? • What about security? Chapter 3  Processes 30

  31. Reason for Migrating Code • Dynamically configuring client • Client fetches necessary software • Then client contacts server Chapter 3  Processes 31

  32. Models for Code Migration • Process consists of 3 segments • Code segment  self explanatory • Resource segment  external resources • Execution segment  current state • Weak mobility migration of code segment and some initialization data • For example, Java applets • Simple, only requires code is portable • Execute in current process, or start new one Chapter 3  Processes 32

  33. Models for Code Migration • Strong mobility migrate exe segment • Running process stopped, moved to another machine, starts where left off • For example, D’Agents • Complex but powerful • Instead of moving the process, might clone the process • Then runs in parallel at client and server • Why? • Cloning improves transparency Chapter 3  Processes 33

  34. Models for Code Migration • Sender or receiver initiated? • Sender initiated • Initiated by machine where code resides • For example, uploading program to server • Other examples? • Receiver initiated • Initiated by target machine • For example, Java applets • Other examples? Chapter 3  Processes 34

  35. Models for Code Migration • Receiver initiated  client takes initiative • Code migrates to client • Done for performance reasons • Sender initiated  server takes initiative • Code migrates to server • Probably want access to server data • Receiver initiated is • Simpler (why?) • More secure (why?) Chapter 3  Processes 35

  36. Models for Code Migration • Alternatives for code migration Chapter 3  Processes 36

  37. Migration and Local Resources • What about resource segment? • Spse process is using a specific port for communication • This info is in resource segment • If process migrates, gets a new port • But an absolute URL will not change • Also in resource segment Chapter 3  Processes 37

  38. Migration and Local Resources • 3 types of process-to-resource binding • Binding by identifier • Known locally and remotely • For example, URL or IP address • Binding by value • Available locally and remotely, but location might be different • C or Java library • Binding by type • Only available locally • Local devices (printers, monitors, etc.) Chapter 3  Processes 38

  39. Migration and Local Resources • 3 types of resource-to-machine bindings • Unattached resources • Easy to move from one machine to another • Such as data files used by programs • Attached resources • Difficult to move from on machine to another • Such as database or entire website • Fixed resources • Cannot be moved • Such as local devices Chapter 3  Processes 39

  40. Migration and Local Resources Resource-to machine binding • GR establish global systemwide reference • MV move the resource • CP copy the file to the resource • RB rebind process to locally available resource Unattached Attached Fixed Process-to-resource binding By identifier By value By type MV (or GR) CP ( or MV, GR) RB (or GR, CP) GR (or MV) GR (or CP) RB (or GR, CP) GR GR RB (or GR) Chapter 3  Processes 40

  41. Migration in Heterogeneous Systems • Code executes on different platforms • Each platform must be supported • Easier if limited to weak mobility • Different code segments • In strong mobility, difficult… • Restrict migration to certain points in code • Such as a function call • Maintain machine independent stack • Migration stack Chapter 3  Processes 41

  42. Migration in Heterogeneous Systems • Maintaining a migration stack to support migration of an execution segment • Can be done in C/C++ Chapter 3  Processes 42

  43. Migration in Heterogeneous Systems • Migration in heterogeneous systems • Basic problem is similar to portability • What is the solution for portability? • Virtual machine is one solution • So similar solution should work here Chapter 3  Processes 43

  44. Code Migration in D'Agents • Middleware approach • Supports various forms of code migration • Read it! Chapter 3  Processes 44

  45. Software Agents • So far • Threads • Clients • Servers • Mobility • And now for something completely different… • Software agents Chapter 3  Processes 45

  46. Software Agents • Software agents  no precise definition • “Autonomous agents capable of performing a task in collaboration with other, possibly remote, agents” • “An autonomous process capable of reacting to, and initiating change in, its environment, possibly in collaboration with users and other agents” • Able to act on its own (autonomous) • Able to cooperate with other agents • Able to take the initiative Chapter 3  Processes 46

  47. Software Agents • Collaborative agents • Agents that work together as part of multiagent system • Example: agents that arrange a meeting • Mobile agents • Able to move between machines • May require strong mobility • Example: to “police” the Internet Chapter 3  Processes 47

  48. Software Agents • Interface agents • Assist users with one or more applications • Actively learns from its interactions • Example: agent that brings buyers and sellers together • Information agents • Manage info from many different sources • In distributed system, info is from physically distributed systems • Example: email agent to filter spam, others? Chapter 3  Processes 48

  49. Software Agents • Properties of software agents Property Common to all agents? Description Autonomous Yes Can act on its own Reactive Yes Responds timely to changes in its environment Proactive Yes Initiates actions that affects its environment Communicative Yes Can exchange information with users and other agents Continuous No Has a relatively long lifespan Mobile No Can migrate from one site to another Adaptive No Capable of learning Chapter 3  Processes 49

  50. Intelligent Agents • Foundation for Intelligent Physical Agents • FIPA • Developing general model for agents • Agents registered at agent platform • Platform provides basic services • Create and delete agents • Locate agents (directory service) • Inter-agent communication facilities Chapter 3  Processes 50

More Related