Chapter 2 Process, Thread and Chapter 2 Process, Thread and - - PowerPoint PPT Presentation

chapter 2 process thread and chapter 2 process thread and
SMART_READER_LITE
LIVE PREVIEW

Chapter 2 Process, Thread and Chapter 2 Process, Thread and - - PowerPoint PPT Presentation

Chapter 2 Process, Thread and Chapter 2 Process, Thread and Scheduling Scheduling Soloris IPC 1 Outline Generic System V IPC Support Shared Memory Shared Memory System V Semaphores System V Message Queues POSIX


slide-1
SLIDE 1

1

Chapter 2 Process, Thread and Chapter 2 Process, Thread and Scheduling Scheduling —— Soloris IPC

slide-2
SLIDE 2

2

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-3
SLIDE 3

3

Generic System V IPC Support

Module Creation

  • The System V IPC kernel modules are implemented as

dynamically loadable modules

  • Each facility has a corresponding loadable module in

the /kernel/sys directory(shmsys, semsys, and msgsys).

  • When an IPC resource is initially created, a positive

integer, known as an identifier, is assigned to identify the IPC object.

slide-4
SLIDE 4

4

Generic System V IPC Support

Resource Maps

  • Two of the three IPC facilities use a low-level kernel

memory allocation scheme known as resource maps.

 message queues  Semaphores

  • Resource maps are a means by which small units of

kernel memory can be allocated and freed from a larger pool of kernel pages that have been preallocated.

  • The amount of space allocated for resource maps for

the IPC facilities is determined by kernel tunable parameters, one parameter each for message queues and semaphores.

slide-5
SLIDE 5

5

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-6
SLIDE 6

6

Shared Memory

 What is shared Memory

  • Shared memory provides an extremely efficient

means of sharing data between multiple processes

  • n a Solaris system
  • The data need not actually be moved from one

process’s address space to another

  • The sharing of the same physical memory (RAM)

pages by multiple processes

  • Each process has mappings to the same physical

pages and can access the memory through pointer dereferencing in code

slide-7
SLIDE 7

7

Shared Memory APIs

 Some implementation APIs

  • shmat(2)
  • shmget(2)
  • shmdt(2)
  • shmctl(2)
slide-8
SLIDE 8

8

Shared Memory APIs

slide-9
SLIDE 9

9

namespace(shmid)

 shmid identifier

  • A shared memory identifier, shmid, is initialized and

maintained by the operating system whenever a shmget(2) system call is executed successfully

  • The shmid identifies a shared segment that has two

components: The actual shared RAM pages A data structure that maintains information about the shared segment, the shmid_ds data structure

slide-10
SLIDE 10

10

Intimate Shared Memory (ISM)

 ISM shared segment

  • Intimate shared memory (ISM) is an optimization

introduced first in Solaris 2.2

  • Allows for the sharing of the translation tables

involved in the virtual -to-physical address translation for shared memory pages

  • As opposed to just sharing the actual physical

memory pages

  • With many processes attaching to shared memory,

this scheme creates a lot of redundant mappings to the same physical pages that the kernel must maintain.

slide-11
SLIDE 11

11

ISM versus Non-ISM

The difference

slide-12
SLIDE 12

12

ISM useful feature

 ISM provides useful feature

  • Translation table sharing
  • Small TLB Page Size
  • Locked pages
  • Default shared memory mode for Oracle RDBMS

System V Semaphores

slide-13
SLIDE 13

13

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-14
SLIDE 14

14

System V Semaphores

What is semaphore

  • A semaphore, as defined in the dictionary, is a

mechanical signalling device or a means of doing visual signalling

  • The analogy typically used is the railroad mechanism of

signalling trains, where mechanical arms would swing down to block a train from a section of track that another train was currently using. When the track was free, the arm would swing up, and the waiting train could then proceed.

slide-15
SLIDE 15

15

System V Semaphores

Two semaphore operations

  • wait and signal (which correlate nicely to the railroad

example). The operations were referred to as P and V

  • perations.
  • The P operation was the wait, which decremented the

value of the semaphore if it was greater than zero

  • The V operation was the signal, which incremented the

semaphore value.

slide-16
SLIDE 16

16

System V Semaphores

Some features about Solaris semaphore

  • The semaphore implementation in Solaris (System V

semaphores) allows for semaphore sets.

  • The actual value of a semaphore can never be

negative.

  • A kernel mutex lock is created for each semaphore set.
  • The creation of a semaphore set by an application

requires a call to semget(2).

slide-17
SLIDE 17

17

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-18
SLIDE 18

18

System V Message Queues

Something about System V Message Queues

  • Message queues provide a means for processes to

send and receive messages of various size in an asynchronous fashion on a Solaris system.

  • Sent messages are placed at the back of the queue,

and messages are received from the front of the queue; thus the queue is implemented as a FIFO (First In, First Out).

slide-19
SLIDE 19

19

System V Message Queues

Kernel Resources for Message Queues

  • The number of resources that the kernel allocates for

message queues is tunable.

  • Values for various message queue tunable parameters

can be increased from their default values so more resources are made available for systems running applications that make heavy use of message queues.

slide-20
SLIDE 20

20

System V Message Queues

The beginning of the map structures used for maintaining resource allocation maps msgque points to the beginning of the kernel space allocated to hold all the system msqid_ds structures.

slide-21
SLIDE 21

21

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-22
SLIDE 22

22

OVERVIEW OF POSIX IPC

The evolution of the POSIX standard and

associated APIs resulted in a set of industry- standard interfaces that provide the same types of facilities as the System V IPC set:

  • shared memory
  • semaphores
  • message queues
slide-23
SLIDE 23

23

POSIX APIs for the three IPC facilities

slide-24
SLIDE 24

24

POSIX Shared Memory

Something about POSIX shared memory

  • The POSIX shared memory interfaces provide an API

for support of the POSIX IPC name abstraction.

  • The interfaces, shm_open(3R) and shm_unlink(3R), do

not allocate or map memory into a calling process’s address space.

  • The programmer using POSIX shared memory must

create the address space mapping with an explicit call to mmap(2)

slide-25
SLIDE 25

25

POSIX Semaphores

The POSIX specification provides for two

types of semaphores

  • POSIX named semaphores follow the POSIX IPC

name convention discussed earlier and are created with the sem_open(3R) call

  • POSIX unnamed semaphores, which do not have a

name in the file system space and are memory based

slide-26
SLIDE 26

26

POSIX Named Semaphores

The linked list exists within the process’s address space, not in the kernel.

Semheadp points to the first semaddr structure on the list sad_next provides the pointer for support of a singly linked list.

slide-27
SLIDE 27

27

POSIX Message Queues

POSIX message queues are constructed on a

linked list built by the internal libposix4 library code.

The essential interfaces for using message

queues are mq_open(3R) which opens, or creates and opens, a queue, making it available to the calling process

slide-28
SLIDE 28

28

POSIX Message Queue Structures

total size in bytes maximum size of each message maximum number of messages allowed on the queue

And so on

slide-29
SLIDE 29

29

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-30
SLIDE 30

30

What is signal

  • Signals are a means by which a process or thread

can be notified of a particular event. Signals are often compared with hardware interrupts, when a hardware subsystem, such as a disk I/O interface (e.g., a SCSI host adapter), generates an interrupt to a processor as a result of an I/O being completed.

  • The signal facility provides a means interrupt a

process or thread within a process as a result of a specific event

Introduction to Solaris signals

slide-31
SLIDE 31

31

Exit

  • Terminate the process

Core

  • Create a core image of the process and terminate

Stop

  • Suspend process execution (typically, job control or

debug)

Ignore

  • Discard the signal and take no action, even if the

signal is blocked

Introduction to Solaris signals

slide-32
SLIDE 32

32

Signal representation

  • Each signal has a unique signal number, we use a

structure member of sufficient width, such that we can represent every signal by simply setting the bit that responds to the signals number of the signal we wish to post.

Introduction to Solaris signals

slide-33
SLIDE 33

33

Figure illustrates all the structures, data types, and linked lists required to support signals in

  • Solaris. There are, of

course, differences between a multithreaded process and a nonthreaded process.

Signal Implementation

slide-34
SLIDE 34

34

High-Level Signal Flow

Signal Implementation

slide-35
SLIDE 35

35

Synchronous signals occur as a direct result

  • f the executing instruction stream, where an

unrecoverble error requires an immediate termination of the process.

Synchronous signals are sometimes referred

to as traps

Synchronous signals

slide-36
SLIDE 36

36

Asynchronous signals are as the term

implies external (and in some cases unrelated) to the current execution context.

Asynchronous signals are also referred to as

interrupts.

Asynchronous signals

slide-37
SLIDE 37

37

Outline

 Generic System V IPC Support 

Shared Memory Shared Memory

 System V Semaphores 

System V Message Queues

 POSIX IPC  Signal  Door

slide-38
SLIDE 38

38

 Door’s function

  • Doors provide a facility for processes to issue

procedure calls to functions in other

  • Using the APIs, a process can become a door

server, exporting a function through a door it creates by using the door_create(3X) interface

  • Other processes can then invoke the procedure by

issuing a door_call(3X), specifying the correct door descriptor

Solaris Doors

slide-39
SLIDE 39

39

How doors provide an IPC

slide-40
SLIDE 40

40

Doors are implemented in the kernel as a

pseudofile system, doorfs, which is loaded from the /kernel/sys directory during boot

Within a process, a door is referenced

through its door descriptor, which is similar in form a function to a file descriptor, and, in fact, the allocation of a door descriptor in a process uses an available file descriptor slot

Doors Implementation

slide-41
SLIDE 41

41

Solaris Doors Structures

slide-42
SLIDE 42

42

Jim Mauro, Richard McDougall, Solaris

Internals-Core Kernel Components, Sun Microsystems Press, 2000

Max Bruning, Threading Model In Solaris,

Training lectures,2005

Solaris internals and performance

management, Richard McDougall, 2002

Reference

slide-43
SLIDE 43

43

End