Operating systems
This presentation is the property of its rightful owner.
Sponsored Links
1 / 92

Operating Systems PowerPoint PPT Presentation


  • 79 Views
  • Uploaded on
  • Presentation posted in: General

Operating Systems. OS. In MIMD systems, several processors are active simultaneously and all processors in execution must be coordinated by the operating system (OS). The OS’s functions are similar to those of SISD machines. OS. The major functions of multiprocessor OS are the following:

Download Presentation

Operating Systems

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Operating systems

Operating Systems


Operating systems

OS

  • In MIMD systems, several processors are active simultaneously and all processors in execution must be coordinated by the operating system (OS). The OS’s functions are similar to those of SISD machines.


Operating systems

OS

  • The major functions of multiprocessor OS are the following:

  • Keep track of the status of all resources (computing, i/o, memory, switches, etc) at any time.

  • Assign tasks to processors according to some optimizing criteria (execution time, processor utilization, etc.).

  • Spawning new tasks or creating new processes such that they can be executed in parallel or independent of each other.

  • Collect individual results and pass them to other processes if required.


What is an operating system

Applications

OS

Hardware

What is an Operating System?

  • An operating system (OS) is:

    • a software layer to abstract away and manage details of hardware resources

    • a set of utilities to simplify application development


The major os issues

The major OS issues

  • structure: how is the OS organized?

  • sharing: how are resources shared across users?

  • naming: how are resources named (by users or programs)?

  • security: how is the integrity of the OS and its resources ensured?

  • protection: how is one user/program protected from another?

  • performance: how do we make it all go fast?


More os issues

More OS issues…

  • concurrency: how are parallel activities (computation and I/O) created and controlled?

  • scale: what happens as demands or resources increase?

  • persistence: how do you make data last longer than program executions?

  • reliability: what happens if something goes wrong (either with hardware or with a program)?

  • extensibility: can we add new features?

  • flexibility: are we in the way of new apps?

  • communication: how do programs exchange information?


Uniprocessor operating systems

Uniprocessor Operating Systems

  • Separating applications from operating system code through

  • a microkernel.

1.11


Multiprocessor operating systems

Multiprocessor Operating Systems

  • The extension from uniprocessor OS to multiprocessor OS is simple: all data structures needed by the OS for resource management are placed in the shared memory. The main difference is that these data are now accessible by multiple CPUs.

  • How to make multiple CPUs transparent to applications?

  • Two important synchronization primitives:

    • Semaphore & Monitor


Synchronization mechanisms

Synchronization mechanisms

  • The semaphore concept was developed by Dijkstra 1968.

  • A semaphore can be though of as an integer with two operations, up and down.

  • The down operation checks to see if the value of a semaphore is greater than 0, if so it decrements and continues, if not the calling process blocks.


Synchronization mechanisms1

Synchronization mechanisms

  • The up operation does the opposite

  • It checks to see if there are any blocked processes, if so it unblocks them and continues, otherwise it simple increments the semaphore.

  • Semaphore operations are atomic.


Synchronization mechanisms2

Synchronization mechanisms

  • Semaphores or prone to errors. The same sort of problems that occur with the goto statement can happen with semaphores.

  • Abundant use of semaphores leads to unstructured code.

  • An alternative is the monitor.


Synchronization mechanisms3

Synchronization mechanisms

  • A monitor is a module consisting of variables and methods.

  • The only way to access a variable is via a monitor method.

  • Monitors are atomic, they don’t allow simultaneous access by 2 or more processes to a monitor method.


Multicomputer operating systems

Multicomputer Operating Systems

  • Multicomputer OS has a totally different structure and complexity from multiprocessor OS because of the lack of physically shared memory for storing data structures for system-wide resource management.

  • General structure of a multicomputer operating system


Distributed shared memory systems

Distributed Shared Memory Systems

  • Still need messages or mechanisms to get data to processor, but these are hidden from the programmer:


Multicomputer operating systems1

Multicomputer Operating Systems

  • Message-passing primitives

Alternatives for blocking and buffering in message passing.


Distributed shared memory systems1

Distributed Shared Memory Systems

  • As we know in distributed memory systems (DMS) there is no single shared memory.

  • From our review of message passing we know that programming DMS is more difficult than programming shared memory systems (SMS).


Distributed shared memory systems2

Distributed Shared Memory Systems

  • DMS are attractive because they are easy to build.

  • However the SMS is more attractive to programmers.


Distributed shared memory systems3

Distributed Shared Memory Systems

  • Distributed Shared Memory systems (DSM) try to address this issue.

  • DSM are designed to provide programmers with a global address space across as DMS.


Distributed shared memory systems4

Distributed Shared Memory Systems


Distributed shared memory systems5

Distributed Shared Memory Systems

  • DSM systems provide the best features of a distributed memory system and shared memory system.


Distributed shared memory system advantages

Distributed Shared Memory System Advantages

  • System scalable

  • Hides the message passing - do not explicitly specific sending messages between processes

  • Can use simple extensions to sequential programming

  • Can handle complex and large data bases without replication or sending the data to processes

  • So what’s the catch?


Distributed shared memory system disadvantages

Distributed Shared Memory System Disadvantages

  • May incur a performance penalty

  • Must provide for protection against simultaneous access to shared data (locks, etc.)

  • Little programmer control over actual messages being generated

  • Performance of irregular problems in particular may be difficult


Distributed shared memory systems6

Distributed Shared Memory Systems

  • Achieving good performance for a restricted class of applications is possible but is a major difficulty when dealing with a sizeable class of applications


Methods of achieving dsm

Methods of Achieving DSM

  • Hardware

    • Special network interfaces and cache coherence circuits

  • Software

    • Modifying the OS kernel Adding a software layer between the operating system and the application


Software dsm implementation

Software DSM Implementation

  • Page based - Using the system’s virtual memory

  • Shared variable approach- Using routines to access shared variables

  • Object based- Shared data within collection of objects. Access to shared data through object oriented discipline (ideally)


Distributed shared memory systems7

Distributed Shared Memory Systems

  • A conventional DSM system implements the shared memory abstraction through a paging system.


Software page based dsm implementation

Software Page Based DSM Implementation


Software page based dsm implementation1

Software Page Based DSM Implementation

  • The primary source of overhead in a conventional DSM is the large amount of communications required to keep memory consistent.


Distributed shared memory systems8

Distributed Shared Memory Systems

  • Pages of address space distributed among four machines

  • Situation after CPU 1 references page 10

  • Situation if page 10 is read only and replication is used


Operating systems

Distributed Shared Memory Systems

  • Replication is used for read operations but when a write occurs all replicated copies must be invalidated.

  • This operation is called write invalidate

  • write-invalidate:the processor that is writing data causes copies in the caches of all other processorsin the system to be rendered invalid before it changes its local copy.


Distributed shared memory systems9

Distributed Shared Memory Systems

  • Another protocol that could be used is the update protocol.

  • Update protocol: update all other copies immediately upon any single update.

  • A broadcast method can be used to accomplish this.

  • Invalidate is preferred since messages are only generated when processors try to access updated copies.


Distributed shared memory systems10

Distributed Shared Memory Systems

  • Ideally we want the DSM system to communicate no more than for the same application executing using MPI.

  • The restrictive nature of the consistency model and inflexible consistency protocols make this difficult to achieve.


Consistency models

Consistency Models

  • Strict Consistency - Processors sees most recent update, i.e. read returns the most recent wrote to location.

  • Sequential Consistency - Result of any execution same as an interleaving of individual programs.

  • Relaxed Consistency- Delay making write visible to reduce messages.

  • Weak consistency - programmer must use synchronization operations to enforce sequential consistency when necessary.

  • Release Consistency - programmer must use specific synchronization operators, acquire and release.

  • Lazy Release Consistency - update only done at time of acquire.


Operating systems

Strict Consistency

  • Defined by the condition

    • Any read on a data item x returns a value corresponding to the result of the most recent write on x.

  • In a distributed system what is the implication of this statement?

    • How is most recent determined?

      • We need a global clock to begin with that yields absolute global time.

    • It also assumes instantaneous communication throughout the distributed system.


Strict consistency

Strict Consistency

  • Every write immediately visible


Operating systems

Sequential Consistency

  • Sequential consistency is slightly weaker than strict consistency.

  • The following condition needs to be satisfied for sequential consistency.

  • The result of any execution is the same as if the (read and write) operations by all processes on the data store executed in some sequential order and the operations of each individual process appeared in this sequence in the order specified by its program.


Operating systems

Sequential Consistency

  • The result of any execution is the same as if the (read and write) operations by all processes on the data store executed in some sequential order and the operations of each individual process appeared in this sequence in the order specified by its program.

  • What does this mean?

    • It means that when processes run concurrently on a distributed system any valid interleaving is acceptable behavior as long as all processes see the same behavior.

    • Note the absence of global time that was seen as necessary in strict consistency.


Operating systems

Sequential Consistency

  • A sequentially consistent data store.

  • A data store that is not sequentially consistent.

Why is (a) okay?


Operating systems

Sequential Consistency

  • A sequentially consistent data store.

  • A data store that is not sequentially consistent.

Why is (a) okay? Because even though it appears the write operation setting x to b appears to have taken place before the write operation setting x to a both P3 and P4 see it the same.

What about (b)?


Operating systems

Weak Consistency

  • Weak consistency model utilizes synchronization variables to synchronize local copies of a data store.

  • When a data store is synchronized, all local writes by a process P are propagated to the other copies, whereas writes by other processes are brought into P’s copy.


Weak consistency

Weak Consistency

  • Properties:

  • Accesses to synchronization variables associated with a data store are sequentially consistent

  • No operation on a synchronization variable is allowed to be performed until all previous writes have been completed everywhere

  • No read or write operation on data items are allowed to be performed until all previous operations to synchronization variables have been performed.


Weak consistency1

Weak Consistency

  • Accesses to synchronization variables associated with a data store are sequentially consistent

  • It does not matter if process P1 call synchronize(S1) at the same time as process P2 calls synchronize(S2), whether S1 occurs before S2 or S2 occurs before S1 as long as they are seen in the same order by all other processes.


Weak consistency2

Weak Consistency

  • No operation on a synchronization variable is allowed to be performed until all previous writes have been completed everywhere.

  • All writes must complete everywhere, this flushes the pipeline, a process doing a synchronization after updating shared data forces all new values out to other local copies. Another synchronization on the same synchronization variable cannot take place until the writes from the last synchronization on that variable are complete.


Weak consistency3

Weak Consistency

  • No read or write operation on data items are allowed to be performed until all previous operations to synchronization variables have been performed.

  • Synchronizations must be complete before reads and writes can go ahead. A process can’t read or write items until the synchronization is complete.


Weak consistency4

Weak Consistency

  • A valid sequence of events for weak consistency.

  • An invalid sequence for weak consistency.

Should be R(x)b


Release consistency

Release Consistency

  • Weak consistency does not distinguish between reads and writes therefore synchronizes on both.

  • An extension of weak consistency in which the synchronization operations have been specified:

    • acquire operation - used before a shared variable or variables are to be read.

    • release operation - used after the shared variable or variables have been altered (written) and allows another process to access to the variable(s)

  • Typically acquire is done with a lock operation and release by an unlock operation (although not necessarily).


Operating systems

Release Consistency

  • Rules:

  • Before a read or write operation on shared data is performed, all previous acquires done by the process must have completed successfully.

  • Before a release is allowed to be performed, all previous reads and writes by the process must have completed

  • Accesses to synchronization variables are FIFO consistent (sequential consistency is not required).


Release consistency1

Release Consistency

Updates are done at the release point


Lazy release consistency

Lazy Release Consistency

Same as release consistency

except updates are done at the acquire.


Consistency models1

Consistency Models

  • One of the problems that need to be addressed that is a side-effect of maintaining consistency in a distributed shared memory systems is false sharing.

  • False sharing is a problem for page-based DSM systems.


Distributed shared memory systems11

Distributed Shared Memory Systems

  • false sharing – different pieces of data belonging to two independent processes in the same page, will cause transferring of the page. Caused by pages being too big.

  • Basically a ping-pong effect is created


Distributed shared memory systems12

Distributed Shared Memory Systems

False sharing of a page between two independent processes.

1.18


Distributed shared memory systems13

Distributed Shared Memory Systems

  • In a conventional message passing system each thread in an application updates it own copy of the data item.

  • A programmer might try to avoid this problem by restructuring their data.

  • Or by introducing new variables to reduce false sharing.

  • Both of these efforts returns the programmer to a difficult programming situation.


Distributed shared memory systems14

Distributed Shared Memory Systems

  • New consistency protocols have been developed by some to address problems like false sharing.


Distributed shared memory systems15

Distributed Shared Memory Systems

  • Software release consistency – requires memory to be consistent only at specific synchronization points.

  • Write-shared protocols – addresses the false sharing issue by allowing multiple processes to write concurrently into a shared page, with updates being merged at appropriate synchronization points.


Operating systems

DSM

  • There are a number of distributed shared memory implementations

  • http://www4.informatik.uni-erlangen.de/Projects/MEMSY/DSM/dsm.html


Adsmith

Adsmith

  • We will briefly look at Adsmith, an object-based DSM

  • A-dsm-ith


Adsmith1

Adsmith

  • User-level libraries that create distributed shared memory system on a cluster.

  • Object based DSM - memory seen as a collection of objects that can be shared among processes on different processors. (more like a shared variable approach)

  • Written in C++

  • Built on top of pvm

  • Freely available

  • User writes application programs in C or C++ and calls Adsmith routines for creation of shared data and control of its access.


Adsmith2

Adsmith

  • By using an shared variable approach a DSM like Adsmith can be implemented on top of existing communication and operating systems.


Adsmith3

Adsmith

  • Adsmith is implemented at the library layer.

  • Only primitives that support data sharing, memory consistency and optimizing communications need be implemented using this approach.


Adsmith4

Adsmith

  • The following slides overview some of the library routines provided by Adsmith


Adsmith routines

Adsmith Routines

  • Process Creation

    • To start a new process or processes: adsm_spawn(filename, count)

    • Exampleadsm_spawn(“prog1”,10);

    • starts 10 copies of prog1 (10 processes).


Adsmith routines1

Adsmith Routines

  • Process join

    • adsmith_wait();

    • will cause the process to wait for all its child processes (processes it created) to terminate.

    • Versions available to wait for specific processes to terminate, using pvm tid to identify processes. Then would need to use the pvm form of adsmith() that returns the tids of child processes.


Adsmith routines2

Adsmith Routines

  • Access to shared data (objects)

    • Adsmith uses “release consistency.” Programmer explicitly needs to control competing read/write access from different processes.

    • Locks can be used to control access.


Adsmith routines3

Adsmith Routines

  • Three types of access in Adsmith, differentiated by the use of the shared data:

    • Ordinary Accesses - For regular assignment statements accessing shared variables.

    • Synchronization Accesses - Competing accesses used for synchronization purposes.

    • Non-Synchronization Accesses - Competing accesses, not used for synchronization.


Adsmith routines4

Adsmith Routines

  • Ordinary Accesses - Basic read/write actions

    • Before read, do:

    • adsm_refresh()

    • to get most recent value - an “acquire/load.” After write to the shared variable, do:

    • adsm_flush()

    • to store result - “store”, updates home location of variable

    • Example

      int *x; //shared variable

      . . .

      adsm_refresh(x);

      a = *x + b;


Adsmith routines5

Adsmith Routines

  • Synchronization accesses

  • To control competing accesses:

    • Semaphores

    • Mutex’s (Mutual exclusion variables)

    • Barriers.

  • All require an identifier to be specified as all three class instances are shared between processes.


Adsmith routines6

Adsmith Routines

  • Semaphore routines

    • Four routines:

    • wait()

    • signal()

    • set()

    • get()


Adsmith routines7

Adsmith Routines

  • Mutual exclusion variables - Mutex

    • Two routines

      • lock

      • unlock()

  • Barrier Routines

    • One barrier routine

      • barrier()


Adsmith routines8

Adsmith Routines

  • Non-synchronization Accesses

    • For competing accesses that are not for synchronization:

      adsm_refresh_now( void *ptr ); and

      adsm_flush_now( void *ptr );

    • refresh and flush take place on home location (rather than locally) and immediately.


Adsmith routines9

Adsmith Routines

  • Features to Improve Performance

    • Routines that can be used to overlap messages or reduce number of messages:

      • Prefetch

      • Bulk Transfer

      • Combined routines for critical sections


Adsmith routines10

Adsmith Routines

  • Prefetch

    adsm_prefetch( void *ptr )

  • used before adsm_refresh() to get data as early as possible. Non-blocking so that can continue with other work prior to issuing refresh.


Adsmith routines11

Adsmith Routines

  • Bulk Transfer

    • Combines consecutive messages to reduce number. Can apply only to “aggregating”:

    • adsm_malloc( AdsmBulkType *type ); adsm_prefetch( AdsmBulkType *type ) adsm_refresh( AdsmBulkType *type ) adsm_flush( AdsmBulkType *type )


Adsmith routines12

Adsmith Routines

  • Routines to improve performance of critical sections Called “Atomic Accesses” in Adsmith.

    adsm_atomic_begin()

    adsm_atomic_end()


Adsmith routines13

Adsmith Routines

  • Sending an expression to be executed on home process

  • Can reduce number of messages. Called “Active Access” in Adsmith. Achieved with:

    adsm_atomic(void *ptr, char *expression);

  • where the expression is written as [type] expression. Object pointed by ptr is the only variable allowed in the expression (and indicated in this expression with the symbol @).


Adsmith routines14

Adsmith Routines

  • Example

    int *x = (int*)adsm_malloc)”x”,sizeofint(int));

    adsm_atomic(x,”[int] @=@+10”);


Adsmith routines15

Adsmith Routines

  • Collect Access

    • Efficient routines for shared objects used as an accumulator:

      void adsm_collect_begin(void *ptr, int num);

      void adsm_collect_end(void *ptr);

    • where num is the number of processes involved in the access, and *ptr points to the shared accumulator


Adsmith routines16

Adsmith Routines

  • Example

    int partial_sum = ... ; // calculate the partial sum

    adsm_collect_begin(sum,nproc);

    sum+=partial_sum; //add partial sum

    adsm_collect_end(sum); //total; sum is returned


Adsmith routines17

Adsmith Routines

  • Message passing Can use PVM routines in same program but must use adsm_spawn() to create processes (not pvm_spawn(). Message tags MAXINT-6 to MAXINT used by Adsmith.


Issues in implementing a dsm system

Issues in Implementing a DSM System

  • Managing shared data

    • reader/writer policies

  • Timing issues

    • relaxing read/write orders


Reader writer policies

Reader/Writer Policies

  • Single reader/single writer policy - simple to do with centralized servers

  • Multiple reader/single writer policy - again quite simple to do

  • Multiple reader/multiple writer policy - tricky


Simple dsm system using a centralized server

Simple DSM system using a centralized server


Simple dsm system using multiple servers

Simple DSM system using multiple servers


Simple dsm system using multiple servers and multiple reader policy

Simple DSM system using multiple servers and multiple reader policy


Operating systems1

Operating Systems

  • Distributed operating systems attempt to make a single virtual image of the memory space.

  • Network Operating Systems provide network services reducing a distributed system’s view to a single system view at the service level. (NFS)


Network operating system

Network Operating System

General structure of a network operating system.

1-19


Network operating system1

Network Operating System

  • Example NOS services:

    • ssh machine

    • scp machine1:file1 machine2:file2

    • File servers.

Two clients and a server in a network operating system.


Network operating system2

Network Operating System

Different clients may mount the servers in different places.

1.21


Positioning middleware

Positioning Middleware

  • The goal of middleware is to combine the best of two worlds:

  • The scalability and openness of NOS.

    • The transparency and ease of use of DOS.

General structure of a distributed system as middleware.


Middleware

Middleware

  • An early example of middleware is RPC’s which hide communications layer from the programmer.


Middleware and openness

Middleware and Openness

In an open middleware-based distributed system, the protocols used by each middleware layer should be the same, as well as the interfaces they offer to applications.

1.23


Comparison between systems

Comparison between Systems

A comparison between multiprocessor operating systems, multicomputer operating systems, network operating systems, and middleware based distributed systems.


  • Login