Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3  Processes 1 Processes Chapter 3 Chapter 3  Processes 2 Introduction  A process is a program in execution  For OS important issues are.

Similar presentations


Presentation on theme: "Chapter 3  Processes 1 Processes Chapter 3 Chapter 3  Processes 2 Introduction  A process is a program in execution  For OS important issues are."— Presentation transcript:

1

2 Chapter 3  Processes 1 Processes Chapter 3

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

4 Chapter 3  Processes 3 Topics Covered  Threads  Clients  Servers  Code Migration  Software Agents

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

6 Chapter 3  Processes 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? o Efficiency  Minuses? o More work for application developer

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

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

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

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

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

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

13 Chapter 3  Processes 12 Multithreaded Servers  Multithreaded server o dispatcher/worker model

14 Chapter 3  Processes 13 Multithreaded Servers  Three ways to construct a server o Single thread  process stalls o Finite state machine  hard to program o Threads  totally awesome, dude  Threads rule! ModelCharacteristics ThreadsParallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Finite-state machineParallelism, nonblocking system calls

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

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

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

18 Chapter 3  Processes 17 X Window System  Organization of X Window System

19 Chapter 3  Processes 18  Consider ATM and TV set-top box o For these, UI is small part of client side o 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) o And not so important Client-Side Transparency

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

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

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

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

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

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

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

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

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

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

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

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

32 Chapter 3  Processes 31 Reason for Migrating Code  Dynamically configuring client o Client fetches necessary software o Then client contacts server

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

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

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

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

37 Chapter 3  Processes 36 Models for Code Migration  Alternatives for code migration

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

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

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

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

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

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

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

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

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

47 Chapter 3  Processes 46 Software Agents  Software agents  no precise definition o “Autonomous agents capable of performing a task in collaboration with other, possibly remote, agents” o “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

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

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

50 Chapter 3  Processes 49 Software Agents  Properties of software agents Capable of learningNoAdaptive Can migrate from one site to anotherNoMobile Has a relatively long lifespanNoContinuous Can exchange information with users and other agents YesCommunicative Initiates actions that affects its environmentYesProactive Responds timely to changes in its environmentYesReactive Can act on its ownYesAutonomous Description Common to all agents? Property

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

52 Chapter 3  Processes 51 FIPA Platform  FIPA model for an agent platform  Agent Communication Channel (ACC) o Sending messages between platforms o Uses Internet Inter-ORB Protocol (IIOP)  Chapter 9

53 Chapter 3  Processes 52 ACL  FIPA defines Agent Communication Language o Defines a “high level communication protocol between a collection of agents” o How does this differ from IIOP?  Separation between msg purpose and content o Header states the msg purpose o Format and language of content is left open o Need enough info in header to interpret content o Ontology: mapping of symbols to meanings

54 Chapter 3  Processes 53 ACL  Different “purposes” in FIPA ACL Message purposeDescription Message Content INFORMInform that a given proposition is trueProposition QUERY-IFQuery whether a given proposition is trueProposition QUERY-REFQuery for a give objectExpression CFPAsk for a proposalProposal specifics PROPOSEProvide a proposalProposal ACCEPT-PROPOSALTell that a given proposal is acceptedProposal ID REJECT-PROPOSALTell that a given proposal is rejectedProposal ID REQUESTRequest that an action be performed Action specification SUBSCRIBESubscribe to an information source Reference to source

55 Chapter 3  Processes 54 ACL Example  Sender INFORMs receiver of Dutch royal genealogy  Ontology says that Prolog statements to be semantically interpreted as genealogy info FieldValue PurposeINFORM Sendermax@http://fanclub-beatrix.royalty-spotters.nl:7239 Receiverelke@iiop://royalty-watcher.uk:5623 LanguageProlog Ontologygenealogy Contentfemale(beatrix),parent(beatrix,juliana,bernhard)

56 Chapter 3  Processes 55 Summary  Threads o Sequential programming o Parallel processing  Clients o User interface o Distribution transparency

57 Chapter 3  Processes 56 Summary  Servers o Efficiency more important than transparency o Interactive or concurrent? o Stateful or stateless? o Object servers  Code migration o Performance and flexibility o Strong mobility vs weak mobility o Local resources? o Heterogeneity/virtual machines

58 Chapter 3  Processes 57 Summary  Software agents o Autonomous and cooperative o Agent communication language (ACL) o Purpose vs content


Download ppt "Chapter 3  Processes 1 Processes Chapter 3 Chapter 3  Processes 2 Introduction  A process is a program in execution  For OS important issues are."

Similar presentations


Ads by Google