Unit- 5
PROCESSES AND
OPERATING
SYSTEMS
1. Introduction
2. Multiple tasks and multiple processes,
Multirate systems
3. Pre-emptive Real time operating systems
4. Priority based Scheduling
5. Interprocess Communication
mechanisms
6. Evaluating Operating system
performance
7. Power optimization strategies for
processes
8. Example Real Time Operating System
(POSIX – Windows CE)
9. Distributed embedded systems
10. MPSoCs and shared memory
multiprocessors
11. Design Example – Audio player
12. Design Example – Engine control unit
13. Design Example – Video accelerator
5. INTER PROCESS COMMUNICATION
Communication between various processes within the system .
Operating system provides mechanism for Inter process communication .
Two ways of communication
1. Blocking – Process waits until it receives a response
2. Non-blocking – Process continues its execution after
sending the message.
(i) Shared memory
(ii)Message passing.
(iii)Signals
(iv)Mailboxes
Inter Process
Techniques in
Communication
(i) Shared memory
 Using bus-based system
 CPU and I/O device can communicate through a shared memory location
 Address of the shared location is known by the software on the CPU and they also loaded into the proper
register of the I/O device
Text Compressor
(ii) Message passing.
 Each communication devices have their own send/receive unit
 Message is stored on the senders/ receivers end points not in communication link
(iii) Signals
A signal is generated by a process and transmitted to
another process by the operating system.
(iv) Mailboxes
 Simple mechanism for asynchronous communication.
 Some architectures define mailbox registers with a fixed number of bits and can be used for small
messages.
 simple version of a mailbox holds only one message at a time.
 Mailbox contains the message and a mail ready flag. The flag is true when a message has been put into
the mailbox and cleared when the message is removed
6. EVALUATING OPERATING SYSTEM PERFORMANCE
Factors that affect the Operating system performance,
 The execution time of the scheduler can be affected by coding practice.
 The Choice of scheduling policy affects the time required by the scheduler to determine the next process
to run.
(i) Context Switching Time
(ii) Interrupt Latency
(iii) Critical Sections and Interrupt Latency
(iv) Interrupt priorities and interrupt latency
(i) Context Switching Time
Context switching time depends on several factors
 The amount of CPU context that must be saved
 Scheduler execution time
(ii) Interrupt Latency
Duration of time from the assertion of a device
interrupt to the completion of the device’s requested
operation
The RTOS can delay the execution of an interrupt
handler in two ways,
(i) Critical sections in the kernel will prevent the
RTOS from taking interrupts.
(ii)Higher-priority interrupt may delay a lower-
priority interrupt.
(iii) Critical Sections and Interrupt Latency
code segment where the shared variables can be accessed
(iv) Interrupt priorities and interrupt
latency
RTOS Performance evaluation tools
Windows CE,
ILTiming, an instrumentation routine in the kernel that
measures both interrupt service routine and interrupt
service thread latency
OSBench - measures the timing of operating system tasks
such as critical section access, signals, and so on
Kernel Tracker - provides a graphical user interface for RTOS
events
7. POWER OPTIMIZATION STRATEGIES FOR PROCESSES
Strategy for determining when to perform certain power management operations.
(i) Predictive Shutdown
Goal is to predict when the next request will be made and to start the system just before that time, saving the requestor the start-
up time
There are two modes; Power –up and power-down.
Technique 1
If the system does not receive inputs during an interval of
length Ton, it shuts down. A powered-down system waits
for a period Toff before returning to the power-on mode.
Technique 2
A more advanced technique is based on amore thorough
Technique 1
Technique 2
(ii) Advanced Configuration and Power Interface (ACPI)
Open industry standard for power management services.
Targeted initially to PCs but designed compatible with a wide variety of operating systems.
8. DISTRIBUTED EMBEDDED SYSTEMS
Processing Element (PE)
Unit which is responsible for the computation within the microprocessor system is termed as processing
element.
A PE may be an instruction set processor such as a DSP, CPU, or microcontroller, as well as a nonprogrammable
unit such as the ASICs or an I/O device.
Network
Group of two or more computer systems liked together
Categories of Multiprocessors
I. Shared memory systems
II. Message passing systems
(i) Network abstractions
Physical Layer
(ii) CAN Bus
CAN is a multi-master message broadcast system
Data frame
When RTR = 0, request data
from the device specified by the
identifier.
When RTR = 1, write data to
the destination identifier.
Bus Arbitration
Carrier Sense Multiple Access with Arbitration on Message Priority (CSMA/AMP).
CAN controllerArchitecture
Bus transaction
 0 for writing from the master to the slave.
 1 for reading from the slave to the master.
Typical bus transactions on the I2C bus.
(iii) I2C bus (Inter-Integrated Circuit)
I2C is a synchronous, multi-master, multi-slave, packet switched
Electrical interface to the I2C bus
An I2C interface in a microcontroller
(iv) Ethernet
Bus Arbitration
Carrier Sense Multiple Access with Collision Detection (CSMA/CD).
Ethernet packet format
(v) Internet
(vi) Transmission Control Protocol (TCP)
9. MPSoCs and shared memory multiprocessors
Accelerators
One important category of processing element for embedded multiprocessors is the accelerator.
can provide large performance increases for applications with computational kernels that spend a great deal
of time in a small section of code
Accelerator System Design
Accelerator performance analysis
The speedup factor depends in part on
whether the system is,
 Single threaded and Multithreaded
 Blocking vs nonblocking
Accelerator execution time
taccel = tin + tx + tout
10. DESIGN EXAMPLE: AUDIO PLAYER
Audio players are also called as MP3 players.
The earliest portable MP3 players were based on compact disc mechanisms. Modern MP3 players use either
flash memory or disk drives to store music.
An MP3 player performs three basic functions,
 Audio storage
 Audio decompression
 User interface
Standard
i) Mpeg Layer 1 Encoder
i) Mpeg Layer 1 Decoder
1. Requirement
2. Specification
Classes in the audio player
State diagram for file display and selection.
State diagram for audio playback.
3. Architecture
Cirrus CS7410 is an audio controller designed for CD/MP3 players
The audio controller includes two processors,
•32-bit RISC processor
•16-bit DSP
The memory controller can be interfaced to
several different types of memory
•Flash memory
•DRAM
The audio interface unit puts out audio in
formats that can be used by A/D converters.
General- purpose I/O pins can be used to
decode buttons, run displays, etc.
Architecture of a Cirrus audio processor for CD/MP3 players.
4. Component design
5. System testing
The most challenging part of system integration and
debugging is ensuring that audio plays smoothly and
without interruption.
 The file system can either implement a known standard such as DOS FAT or can implement a new file system.
 While a nonstandard file system may be easier to implement on the device, it also requires software to create the file
system.
 The audio output system should be tested separately from the compression system. Testing of audio decompression
requires sample audio files
11. DESIGN EXAMPLE: ENGINE CONTROL UNIT
• ECU is a generic term for any embedded
system that controls one or more of the
electrical system or subsystem in a motor
vehicle.
• ECU is a type of electronic control unit that
controls a series of actuators on a internal
combustion engine to ensure optimal
engine performance.
THEORY OF OPERATION:
The throttle is the command input.
The engine measures throttle, RPM, intake air
volume, and other variables.
The engine controller computes injector pulse
width and spark.
1. Requirement
2. Specification
3. Architecture
Class diagram for the engine controller.
4. Component design and testing
 The RTOS initialization phase is used to set up the task periods.
 Because some of the output variables depend on changes in state, these tasks should be tested with multiple input
variable sequences to ensure that both the basic and adjustment calculations are performed correctly.
5. System integration and testing
Any testing performed on an actual engine must be
conducted using an engine controller that has been
designed to withstand the harsh environment of the engine
compartment.
12. DESIGN EXAMPLE: VIDEO ACCELERATOR
A video accelerator is a video card with integrated processor and memory to increase the overall
capabilities of video graphics
Concentrates on motion estimation accelerator
Motion estimation accelerator
Process of determining the motion vector that describe the
transformation from one 2D image to the another.
Concept of Block motion Estimation
1. Requirement
2. Specification
3. Architecture
Object diagram for the video accelerator
4. Component design
 Uses a standard FPGA accelerator board to implement the accelerator
 If designing own accelerator board, it is compulsory to design both the video accelerator design and the interface to the PCI
bus
 video accelerator architecture can be created and exercised in a hardware description language like VHDL or Verilog
5. System testing
Testing video algorithms requires a large amount of data
As the design is only a motion estimation it is probably
easiest to use images, not video for test data.
Open source for JPEG encoders and decoders is available.
These programs can be modified to read JPEG images and
put out pixels in the format required by your accelerator
13.(A) Example Real Time Operating System (Windows CE)
Windows CE is an operating system developed by Microsoft and designed for small footprint devices
or embedded systems.
supports devices such as smartphones, electronic instruments, etc.
designed to run on multiple hardware platforms and instruction set architectures.
WinCEArchitecture
WinCE layer diagram
OAL (OEM Adaption Layer )Architecture
WinCE Memory space
User address space in Windows CE.
 The top 1 GB is reserved for system elements such as DLLs (Dynamic-link library),
memory mapped files, and shared system heap.
 The bottom 1 GB holds user elements such as code, data, stack, and heap.
WinCE interrupts
1. Interrupt service handler (ISH) - Kernel service that provides the first response to the interrupt.
2. Interrupt service routine (ISR) - ISH selects an interrupt service routine (ISR) to handle the interrupt.
The ISH runs in the kernel with interrupts turned off; as a result, it should be designed to do as little direct work as
possible.
3. Interrupt service thread (IST) - performs most of the work required to handle the interrupt.
The IST runs in the OAL and so can be interrupted by a higher-priority interrupt.
13.(B) Example Real Time Operating System (POSIX)
POSIX is a version of the Unix operating system created by a standards organization.
Unix was not originally designed as a real-time operating system; POSIX has been extended to support Realtime
requirements.
1. Processes in POSIX
(i) fork ( ) function
A process makes a copy of itself by calling the fork ( ) function.
That function causes the operating system to create a new process (the child process) which is a
nearly exact copy of the process that called fork ( ) (the parent process).
They both share the same code and the same data values with one exception, the return value
of fork ( ): the parent process is returned the process ID number of the child process, while the
child process gets a return value of 0.
childid = fork ( );
if (childid == 0) { /* must be the child */
/* do child process here */
}
(ii) execv ( ) function
used to overlay the child process with the appropriate code
childid = fork ( );
if (childid == 0) { /* must be the child */
execv(“mychild”, childargs);
exit(1);
}
The execv ( ) function takes as argument the name of the file that
holds the child’s code and the array of arguments.
It overlays the process with the new code and starts executing it
from the main ( ) function.
(iii) exit ( ) function
The exit() function is a C
function that is used to leave a
process
The parent process should use one of the POSIX wait functions before calling
exit() for itself.
The wait functions returns the child process’s status, they also make sure that the
child’s resources (namely memory) are free.
childid = fork ( );
if (childid == 0) { /* must be the child */
execv(“mychild”,childargs);
perror(“execl”);
exit(1);
}
else { /* is the parent */
parent_stuff(); /* execute parent functionality */
wait(&cstatus);
exit(0);
}
(iv) wait ( ) function
(v) parent_stuff ( )
The parent_stuff ( ) function performs the work of the
parent function.
2. Real time scheduling in POSIX
(i) sched_setscheduler() function
(ii)SCHED_FIFO policy
#include <sched.h>
int i, my_process_id;
struct sched_param my_sched_params;
…
i = sched_setscheduler(my_process_id,SCHED_FIFO,&sched_params);
Two other useful functions allow a process to determine the minimum and maximum priority values in
the system:
minval = sched_get_priority_min(SCHED_RR);
maxval = sched_get_priority_max(SCHED_RR);
(iii) sched_getparams ( )
The sched_getparams ( ) function returns the current parameter values for a process.
(iv) sched_setparams ( )
sched_setparams ( ) changes the parameter values
(v) sched_yield() function
Whenever a process changes its priority, it is put at the back of the
queue for that
priority level.
A process can also explicitly move itself to the end of its priority queue
with a call to the sched_yield() function.
3. POSIX Pipes
(i) pipe ( ) function
A parent process uses the
pipe ( ) function to create a
pipe to talk to a child.
It must do so before the
child itself is created.
if (pipe(pipe_ends) < 0) { /* create the pipe, check for errors */
perror(“pipe”);
break;
}
/* create the process */
childid = fork();
if (childid == 0) { /* the child reads from pipe_ends[1]*/
childargs[0] = pipe_ends[1];
/* pass the read end descriptor to the new incarnation of child */
execv(“mychild”,childargs);
perror(“execv”);
exit(1);
}
else { /* the parent writes to pipe_ends[0] */
}
4. POSIX message passing
POSIX also supports message queues under the _POSIX_MESSAGE_PASSING facility.
The advantage of a queue over a pipe is that, because queues have names, we don’t have to create the pipe
descriptor before creating the other process using it.
The name of a starts with a “/”,
(i) myq
The queue descriptor myq is used to enqueue and
dequeue messages.
(ii) MQ_PRIO_MAX
Messages can be prioritized, with a priority value
between 0 and MQ_PRIO_MAX (there are at least 32
priorities available).
(iii) mq_close ( )
When a process is done with a queue, it calls mq_close (
).
i = mq_close(myq);
THANK YOU

EC8791-U5-PPT.pptx

  • 1.
    Unit- 5 PROCESSES AND OPERATING SYSTEMS 1.Introduction 2. Multiple tasks and multiple processes, Multirate systems 3. Pre-emptive Real time operating systems 4. Priority based Scheduling 5. Interprocess Communication mechanisms 6. Evaluating Operating system performance 7. Power optimization strategies for processes 8. Example Real Time Operating System (POSIX – Windows CE) 9. Distributed embedded systems 10. MPSoCs and shared memory multiprocessors 11. Design Example – Audio player 12. Design Example – Engine control unit 13. Design Example – Video accelerator
  • 2.
    5. INTER PROCESSCOMMUNICATION Communication between various processes within the system . Operating system provides mechanism for Inter process communication . Two ways of communication 1. Blocking – Process waits until it receives a response 2. Non-blocking – Process continues its execution after sending the message. (i) Shared memory (ii)Message passing. (iii)Signals (iv)Mailboxes Inter Process Techniques in Communication
  • 3.
    (i) Shared memory Using bus-based system  CPU and I/O device can communicate through a shared memory location  Address of the shared location is known by the software on the CPU and they also loaded into the proper register of the I/O device Text Compressor
  • 4.
    (ii) Message passing. Each communication devices have their own send/receive unit  Message is stored on the senders/ receivers end points not in communication link (iii) Signals A signal is generated by a process and transmitted to another process by the operating system.
  • 5.
    (iv) Mailboxes  Simplemechanism for asynchronous communication.  Some architectures define mailbox registers with a fixed number of bits and can be used for small messages.  simple version of a mailbox holds only one message at a time.  Mailbox contains the message and a mail ready flag. The flag is true when a message has been put into the mailbox and cleared when the message is removed
  • 6.
    6. EVALUATING OPERATINGSYSTEM PERFORMANCE Factors that affect the Operating system performance,  The execution time of the scheduler can be affected by coding practice.  The Choice of scheduling policy affects the time required by the scheduler to determine the next process to run. (i) Context Switching Time (ii) Interrupt Latency (iii) Critical Sections and Interrupt Latency (iv) Interrupt priorities and interrupt latency
  • 7.
    (i) Context SwitchingTime Context switching time depends on several factors  The amount of CPU context that must be saved  Scheduler execution time (ii) Interrupt Latency Duration of time from the assertion of a device interrupt to the completion of the device’s requested operation The RTOS can delay the execution of an interrupt handler in two ways, (i) Critical sections in the kernel will prevent the RTOS from taking interrupts. (ii)Higher-priority interrupt may delay a lower- priority interrupt.
  • 8.
    (iii) Critical Sectionsand Interrupt Latency code segment where the shared variables can be accessed (iv) Interrupt priorities and interrupt latency RTOS Performance evaluation tools Windows CE, ILTiming, an instrumentation routine in the kernel that measures both interrupt service routine and interrupt service thread latency OSBench - measures the timing of operating system tasks such as critical section access, signals, and so on Kernel Tracker - provides a graphical user interface for RTOS events
  • 9.
    7. POWER OPTIMIZATIONSTRATEGIES FOR PROCESSES Strategy for determining when to perform certain power management operations. (i) Predictive Shutdown Goal is to predict when the next request will be made and to start the system just before that time, saving the requestor the start- up time There are two modes; Power –up and power-down. Technique 1 If the system does not receive inputs during an interval of length Ton, it shuts down. A powered-down system waits for a period Toff before returning to the power-on mode. Technique 2 A more advanced technique is based on amore thorough
  • 10.
  • 11.
  • 12.
    (ii) Advanced Configurationand Power Interface (ACPI) Open industry standard for power management services. Targeted initially to PCs but designed compatible with a wide variety of operating systems.
  • 13.
    8. DISTRIBUTED EMBEDDEDSYSTEMS Processing Element (PE) Unit which is responsible for the computation within the microprocessor system is termed as processing element. A PE may be an instruction set processor such as a DSP, CPU, or microcontroller, as well as a nonprogrammable unit such as the ASICs or an I/O device. Network Group of two or more computer systems liked together
  • 14.
    Categories of Multiprocessors I.Shared memory systems II. Message passing systems
  • 15.
    (i) Network abstractions PhysicalLayer (ii) CAN Bus CAN is a multi-master message broadcast system Data frame When RTR = 0, request data from the device specified by the identifier. When RTR = 1, write data to the destination identifier.
  • 16.
    Bus Arbitration Carrier SenseMultiple Access with Arbitration on Message Priority (CSMA/AMP). CAN controllerArchitecture
  • 17.
    Bus transaction  0for writing from the master to the slave.  1 for reading from the slave to the master. Typical bus transactions on the I2C bus. (iii) I2C bus (Inter-Integrated Circuit) I2C is a synchronous, multi-master, multi-slave, packet switched Electrical interface to the I2C bus
  • 18.
    An I2C interfacein a microcontroller (iv) Ethernet
  • 19.
    Bus Arbitration Carrier SenseMultiple Access with Collision Detection (CSMA/CD). Ethernet packet format
  • 20.
    (v) Internet (vi) TransmissionControl Protocol (TCP)
  • 21.
    9. MPSoCs andshared memory multiprocessors Accelerators One important category of processing element for embedded multiprocessors is the accelerator. can provide large performance increases for applications with computational kernels that spend a great deal of time in a small section of code Accelerator System Design
  • 22.
    Accelerator performance analysis Thespeedup factor depends in part on whether the system is,  Single threaded and Multithreaded  Blocking vs nonblocking
  • 23.
  • 24.
    10. DESIGN EXAMPLE:AUDIO PLAYER Audio players are also called as MP3 players. The earliest portable MP3 players were based on compact disc mechanisms. Modern MP3 players use either flash memory or disk drives to store music. An MP3 player performs three basic functions,  Audio storage  Audio decompression  User interface
  • 25.
  • 26.
    i) Mpeg Layer1 Encoder
  • 27.
    i) Mpeg Layer1 Decoder
  • 28.
  • 29.
  • 30.
    State diagram forfile display and selection.
  • 31.
    State diagram foraudio playback.
  • 32.
    3. Architecture Cirrus CS7410is an audio controller designed for CD/MP3 players The audio controller includes two processors, •32-bit RISC processor •16-bit DSP The memory controller can be interfaced to several different types of memory •Flash memory •DRAM The audio interface unit puts out audio in formats that can be used by A/D converters. General- purpose I/O pins can be used to decode buttons, run displays, etc. Architecture of a Cirrus audio processor for CD/MP3 players.
  • 33.
    4. Component design 5.System testing The most challenging part of system integration and debugging is ensuring that audio plays smoothly and without interruption.  The file system can either implement a known standard such as DOS FAT or can implement a new file system.  While a nonstandard file system may be easier to implement on the device, it also requires software to create the file system.  The audio output system should be tested separately from the compression system. Testing of audio decompression requires sample audio files
  • 34.
    11. DESIGN EXAMPLE:ENGINE CONTROL UNIT • ECU is a generic term for any embedded system that controls one or more of the electrical system or subsystem in a motor vehicle. • ECU is a type of electronic control unit that controls a series of actuators on a internal combustion engine to ensure optimal engine performance. THEORY OF OPERATION: The throttle is the command input. The engine measures throttle, RPM, intake air volume, and other variables. The engine controller computes injector pulse width and spark.
  • 35.
  • 36.
  • 37.
    3. Architecture Class diagramfor the engine controller.
  • 38.
    4. Component designand testing  The RTOS initialization phase is used to set up the task periods.  Because some of the output variables depend on changes in state, these tasks should be tested with multiple input variable sequences to ensure that both the basic and adjustment calculations are performed correctly. 5. System integration and testing Any testing performed on an actual engine must be conducted using an engine controller that has been designed to withstand the harsh environment of the engine compartment.
  • 39.
    12. DESIGN EXAMPLE:VIDEO ACCELERATOR A video accelerator is a video card with integrated processor and memory to increase the overall capabilities of video graphics Concentrates on motion estimation accelerator Motion estimation accelerator Process of determining the motion vector that describe the transformation from one 2D image to the another.
  • 40.
    Concept of Blockmotion Estimation
  • 41.
  • 42.
  • 43.
  • 44.
    Object diagram forthe video accelerator
  • 45.
    4. Component design Uses a standard FPGA accelerator board to implement the accelerator  If designing own accelerator board, it is compulsory to design both the video accelerator design and the interface to the PCI bus  video accelerator architecture can be created and exercised in a hardware description language like VHDL or Verilog 5. System testing Testing video algorithms requires a large amount of data As the design is only a motion estimation it is probably easiest to use images, not video for test data. Open source for JPEG encoders and decoders is available. These programs can be modified to read JPEG images and put out pixels in the format required by your accelerator
  • 46.
    13.(A) Example RealTime Operating System (Windows CE) Windows CE is an operating system developed by Microsoft and designed for small footprint devices or embedded systems. supports devices such as smartphones, electronic instruments, etc. designed to run on multiple hardware platforms and instruction set architectures. WinCEArchitecture WinCE layer diagram
  • 47.
    OAL (OEM AdaptionLayer )Architecture
  • 48.
    WinCE Memory space Useraddress space in Windows CE.  The top 1 GB is reserved for system elements such as DLLs (Dynamic-link library), memory mapped files, and shared system heap.  The bottom 1 GB holds user elements such as code, data, stack, and heap.
  • 49.
    WinCE interrupts 1. Interruptservice handler (ISH) - Kernel service that provides the first response to the interrupt. 2. Interrupt service routine (ISR) - ISH selects an interrupt service routine (ISR) to handle the interrupt. The ISH runs in the kernel with interrupts turned off; as a result, it should be designed to do as little direct work as possible. 3. Interrupt service thread (IST) - performs most of the work required to handle the interrupt. The IST runs in the OAL and so can be interrupted by a higher-priority interrupt.
  • 51.
    13.(B) Example RealTime Operating System (POSIX) POSIX is a version of the Unix operating system created by a standards organization. Unix was not originally designed as a real-time operating system; POSIX has been extended to support Realtime requirements. 1. Processes in POSIX (i) fork ( ) function A process makes a copy of itself by calling the fork ( ) function. That function causes the operating system to create a new process (the child process) which is a nearly exact copy of the process that called fork ( ) (the parent process). They both share the same code and the same data values with one exception, the return value of fork ( ): the parent process is returned the process ID number of the child process, while the child process gets a return value of 0.
  • 52.
    childid = fork( ); if (childid == 0) { /* must be the child */ /* do child process here */ } (ii) execv ( ) function used to overlay the child process with the appropriate code childid = fork ( ); if (childid == 0) { /* must be the child */ execv(“mychild”, childargs); exit(1); } The execv ( ) function takes as argument the name of the file that holds the child’s code and the array of arguments. It overlays the process with the new code and starts executing it from the main ( ) function.
  • 53.
    (iii) exit () function The exit() function is a C function that is used to leave a process The parent process should use one of the POSIX wait functions before calling exit() for itself. The wait functions returns the child process’s status, they also make sure that the child’s resources (namely memory) are free. childid = fork ( ); if (childid == 0) { /* must be the child */ execv(“mychild”,childargs); perror(“execl”); exit(1); } else { /* is the parent */ parent_stuff(); /* execute parent functionality */ wait(&cstatus); exit(0); } (iv) wait ( ) function (v) parent_stuff ( ) The parent_stuff ( ) function performs the work of the parent function.
  • 54.
    2. Real timescheduling in POSIX (i) sched_setscheduler() function (ii)SCHED_FIFO policy #include <sched.h> int i, my_process_id; struct sched_param my_sched_params; … i = sched_setscheduler(my_process_id,SCHED_FIFO,&sched_params);
  • 55.
    Two other usefulfunctions allow a process to determine the minimum and maximum priority values in the system: minval = sched_get_priority_min(SCHED_RR); maxval = sched_get_priority_max(SCHED_RR); (iii) sched_getparams ( ) The sched_getparams ( ) function returns the current parameter values for a process. (iv) sched_setparams ( ) sched_setparams ( ) changes the parameter values (v) sched_yield() function Whenever a process changes its priority, it is put at the back of the queue for that priority level. A process can also explicitly move itself to the end of its priority queue with a call to the sched_yield() function.
  • 56.
    3. POSIX Pipes (i)pipe ( ) function A parent process uses the pipe ( ) function to create a pipe to talk to a child. It must do so before the child itself is created. if (pipe(pipe_ends) < 0) { /* create the pipe, check for errors */ perror(“pipe”); break; } /* create the process */ childid = fork(); if (childid == 0) { /* the child reads from pipe_ends[1]*/ childargs[0] = pipe_ends[1]; /* pass the read end descriptor to the new incarnation of child */ execv(“mychild”,childargs); perror(“execv”); exit(1); } else { /* the parent writes to pipe_ends[0] */ }
  • 57.
    4. POSIX messagepassing POSIX also supports message queues under the _POSIX_MESSAGE_PASSING facility. The advantage of a queue over a pipe is that, because queues have names, we don’t have to create the pipe descriptor before creating the other process using it. The name of a starts with a “/”, (i) myq The queue descriptor myq is used to enqueue and dequeue messages. (ii) MQ_PRIO_MAX Messages can be prioritized, with a priority value between 0 and MQ_PRIO_MAX (there are at least 32 priorities available). (iii) mq_close ( ) When a process is done with a queue, it calls mq_close ( ). i = mq_close(myq);
  • 58.