Devices and Communication Buses For Devices Network
Devices and Communication Buses For Devices Network
SPI Cont.
The Serial Peripheral Interface is essentially a shift register that serially transmits data bits to other SPIs. During a data transfer, one SPI system acts as the "master" which controls the data flow, while the other devices act as "slaves" which have data shifted into and out by the master.
SCLK, MOSI and MISO signals for serial clock from master, output from master and input to master, respectively. Device selection as master or slave can be done by a signal to hardware input SS. (Slave select when 0) pin
Master In Slave Out (MISO): This data line supplies the output data from a slave to the input of the master. There may be no more than one slave transmitting data during any particular transfer.
Serial Clock (SPCK/SCLK): This control line is driven by the master and regulates the flow of the data bits. The master may transmit data at a variety of baud rates; the SPCK/SCLK line cycles once for each bit that is transmitted. Slave Select (NSS/SS): This control line allows slaves to be turned on and off by hardware.
MOSI
SPI Slave #2
Examples
68HC11/12 uses synchronous serial communication (SPI Protocol)
68HC12 provides SPI communication device operation at 4Mbps. 68HC11 provides SPI communication device operation at 2Mbps.
The SCI consists of separate transmit and receive sections whose operations can be asynchronous with respect to each other.
SCI Features
Three-Pin Interface:
TXD Transmit Data RXD Receive Data SCLK Serial Clock(Optional for Synchronous Communication)
781.25 Kbps NRZ Asynchronous Communications Interface (50-MHz System Clock) 6.25 Mbps Synchronous Serial Mode (50-MHz System Clock)
Two Wakeup Modes: Idle Line and Address Bit Wired-OR Mode
On-Chip or External Baud Rate Generation/Interrupt Timer Four Interrupt Priority Levels Fast or Long Interrupts
The SCI configuration allows for a number of options for data transmission and reception. In the simplest configuration, ten bits are involved : a start bit (logical 0), the 8 data bits, and a stop bit (logical 1). An example transmission waveform, such as what you might see if you hooked up a logic analyzer to the TX pin, is shown above. Note that the data bits are sent lsb (bit 0) first, and msb (bit 7) last. Thus, the middle 8 bits in the pulse train below are sent in the order "10110100" in a time domain signal, corresponding to an actual data byte of 0x2D (%0010 1101), which is an ASCII minus " - " sign.
The data rate out of/into the SCI is determined by the baud rate, and is an essential value to consider in any SCI setup.
For our Dragon 12 running with a PLL controlled clock at 24 MHz, the baud rate is determined by the following formula:
SCI BAUD rate = 24,000,000/(16 x BR)
where BR is the content of the SCI1BDH/L Baud Rate Registers at addresses $00D0 and $00D1. For example, for a baud rate of 9600 (baud period ~ 100 usec) , we want a BR of about 156 = $9C, so we write $00 to SCI1BDH and $9C to SCI1BDL. Note that the baud rate is the same for transmission and reception for a given SCI port; we can't set one baud rate for transmission, and another for reception on a given port.
(1) We wait for the shift register connected to the RX pin to fill with serial data;
(2) Once the RX shift register is filled, the data is immediately transferred to the data register (the transfer is automatically done by the hardware);
(3) We then read the data register to see what data was received.
SDIO card has become popular feature in handheld mobile devices, PDAs, digital cameras and embedded systems.
SD card size just 0.14 cm 2.4 cm 3.2 cm. Allowed to stick out of the handheld device open slot, which can be at the top in order to facilitate insertion of the SD card
4. Speed Class
Four Speed Classes are defined and indicate minimum performance of the cards Class 0 - These class cards do not specify performance. It includes all the legacy cards prior to specification 2.00, regardless of its performance Class 2 - Are more than or equal to 2 MB/sec performance. Class 4 - Are more than or equal to 4 MB/sec performance. Class 6 - Are more than or equal to 6 MB/sec performance.
5. Bus Topology
The SD bus includes the following 9 signals: CLK : Host to card clock signal CMD : Bidirectional Command/Response signal DAT 0 - DAT 3 : 4 Bidirectional data signals. VDD , VSS1 , VSS2 : Power and ground signals.
6. Bus Protocol Communication over the SD bus is based on command and data bit streams that are initiated by a start bit and terminated by a stop bit. Command: a command is a token that starts an operation. A command is sent from the host either to a single card (addressed command) or to all connected cards (broadcast command). A command is transferred serially on the CMD line. Response: a response is a token that is sent from an addressed card, or (synchronously) from all connected cards, to the host as an answer to a previously received command. A response is transferred serially on the CMD line.
Data: data can be transferred from the card to the host or vice versa. Data is transferred via the data lines.
Parallel Port
8-bit IOs Short distances, generally within a circuit board or IC or nearby external devices
Disadvantage
More number of wires Capacitive effect in parallel wires reduces the length up to which communication in parallel can take place. High capacitance results in delay for the bits at the other end undergoing transition from 0 to 1 or 1 to 0. High capacitance can also result in noise and cross talk (induced signals) between the wires.
Handshaking signals to and from an external peripheral device for input at port
Device makes a strobe request to port, STROBE after it is ready to send the byte and System I/O port sends the acknowledgement, PORT READY. System I/O port receives data in buffer and then issues an interrupt signal, INT to processor to enable an ISR execution
Handshaking signals to and from an external peripheral device for Output at port
Device sends the message ACKNOWLEDGE when and the I/O device port ends the BUFFER FULL signal to inform that the is buffer full. The processor is sent the INTERRUPT REQUEST message, when the transmitting-buffer is empty (available for next write)
Introduction to I2C
I2C is well known bus invented by PHILIPS. I2C stands for INTER-INTEGRATED CIRCUIT. These type of bus is famous in TV circuit board and then it come to computer environment. It has speed of 100kbs but it can be extended to 450kbps. But only the problem is our processor has a capability of I2C protocol bus inbuilt.
Technical Specifications
Idle
CAN Protocol
60
Physical medium two wires terminated at both ends by resistors. Differential signal - better noise immunity. Benefits: Reduced weight, Reduced cost Fewer wires = Increased reliability
vs.
http://canbuskit.com/what.php
61
CAN bus
62
Message Format
Each message has an ID, Data and overhead. Data 8 bytes max Overhead start, end, CRC, ACK
63
Bus Arbitration
Arbitration needed when multiple nodes try to transmit at the same time Only one transmitter is allowed to transmit at a time. A node waits for bus to become idle
CAN bus
64
Bus Arbitration
Message importance is encoded in message ID. Lower value = More important As a node transmits each bit, it verifies that it sees the same bit value on the bus that it transmitted. A 0 on the bus wins over a 1 on the bus. Losing node stops transmitting, winner continues.
65
CAN protocol
There is a CAN controller between the CAN line and the host node. CAN controller BIU (Bus Interface Unit) consisting of a buffer and driver Method for arbitration CSMA/AMP (Carrier Sense Multiple Access with Arbitration on Message Priority basis)
Physical Layer
It has two states
1. Dominant State(Logic 0) 2. Recessive State(Logic 1)
There are 5-fields in CAN data Frame Format and START & STOP Bits 1. Arbitration field
2.
3. 4. 5.
11-bit destination address and RTR bit (Remote Transmission Request) Destination device address specified in an 11-bit subfield and whether the data byte being sent is a data for the device or a request to the device in 1-bit sub-field.
Maximum 211 devices can connect a CAN controller in case of 11-bit address field standard
Arbitration Field
Identifies(11 bits) the device to which data is being sent or request is being made. When RTR bit is at '1', it means this packet is for the device at destination address. If this bit is at '0' (dominant state) it means, this packet is a request for the data from the device.
CRC Field
Fourth field (third if data field has no bit present) of 16 bits CRC (Cyclic Redundancy Check) bits. The receiver node uses it to detect the errors, if any, during the transmission
ACK Field
Fifth field of 2 bits First bit 'ACK slot' ACK = '1 BIT' and receiver sends back '0' in this slot when the receiver detects an error in the reception. Sender after sensing '0' in the ACK slot, generally retransmits the data frame. Second bit 'ACK delimiter' bit. It signals the end of ACK field.
If the transmitting node does not receive any acknowledgement of data frame within a specified time slot, it should retransmit.
EOF Field
Sixth field of 7-bits end- of- the frame specification and has seven '0's
Summary
CAN bus Controller Area Network bus Primarily used for building ECU (Engine control unit) networks in automotive applications. Two wires OSI - Physical and Data link layers Differential signal - noise immunity 1Mbit/s, 120 Messages contain up to 8 bytes of data
77
Self Study
USB Protocol..!!!
80
94
This configuration allowed for higher performance without slowing down the processor
The PCI Bus was originally 33Mhz and then changed to 66Mhz. PCI Bus became big with the release of Windows 95 with Plug and Play technology.
95
96
97
98
High Bandwidth Options: allows for increased speed of the PCI. PCI driver can access the hardware automatically as well as by the programmer assigned addresses.
and
100
PCI
64 bits
133 MHz
1 GBps
very high speed, Plug & Play, dominant boardlevel bus designed for industrial use, hot swapping/Plug & Play, ideal for embedded systems
incompatible with older systems, can cost more lower speed than PCI, need adapter for PC use, incompatible with older systems
CompactPCI
64 bits
33MHz
132 MBps
Table 1: How PCI compares to other buses (Tyson, 2004a; Quatech, 2004c)
101
Tasks it automates:
Interrupt Requests (IRQ) Direct Memory Access (DMA) Memory Addresses Input/Output (I/O) Configuration
102
4.
103
104
3.
If the sound card is in recording mode, the bus controller will assign a high priority to the data coming from the sound card. It will send the sound cards data over the bus bridge to the system bus.
The system bus will save the data in system memory. When the recording is complete, then it will be up to the user to save the data from the sound card on either the hard drive, or will remain in memory for additional processing.
105
2.
4.
106
Used in high bandwidth devices (Fiber Channel, and processors that are part of a cluster and Gigabit Ethernet)
Maximum 264 MBps throughput, uses 8, 16, 32, or 64 bit transfers
107
ARM BUS
Self study
109
Overview of Bluetooth
What is Bluetooth?
Bluetooth is a short-range wireless communications technology. Works on Unlicensed ISM Band of 2.4GHz Frequency. Devices within 10 m can share up to 720 kbps of capacity Point-to-point or point-to-multiple points Voice and Data Supports both synchronous and asynchronous services
Why Bluetooth?
Cable replacement between devices. Supported by major companies. Low power consumption Connection can be initiated without user interaction. Devices can be connected to multiple devices at the same time.
Piconet It is the network formed by a Master and one or more slaves (max 7) Each piconet is defined by a different hopping channel to which users synchronize to Each piconet has max capacity (1 Mbps)
Piconet Structure
S S
S S M
M S
S S
S S
S
Multiple piconets can operate within same physical space This is an ad-hoc, peer to peer (P2P) network
Radio or Antenna
Bluetooth devices operate on 2.4 GHz Industrial Scientific Medical band (ISM band). Unlicensed in most countries.
Techniques to minimize packet loss: Frequency Hopping Adaptive power control Short data packets
Frequency Hopping
The master shall start its transmission in even-numbered time slots only, and the slave shall start its transmission in odd-numbered time slots only. The packet start shall be aligned with the slot start.
119
Multislot Frames
For a multislot packet, the RF hop frequency to be used for the entire packet is derived from the Bluetooth clock value in the first slot of the packet. The RF hop frequency in the first slot after a multislot packet shall use the frequency as determined by the current Bluetooth clock value.
Baseband layer
Baseband protocol
AMA: PMA: Active Member address Parked Member address
Standby Waiting to join a piconet Unconnected: Standby Inquire Ask about available radios Page Connecting states Connect to a specific radio Connected Actively on a piconet (master Active states or slave) Park/Hold Low-power connected states
Low-power states
Standby
Inquiry
Page
Connected AMA
PARK PMA
HOLD AMA
122
Baseband: Links
Between master and slave(s), two different types of links can be established
Synchronous Connection-Oriented (SCO) link a symmetric point-to-point link between a master and a single slave in the piconet Uses reserved slots to support circuit-switched connection The master can support up to three SCO links to the same slave or to different slaves Asynchronous Connection-Less (ACL) link Asymmetric point-to-multipoint link between master and all active slaves participating in the piconet Uses the slots that are not reserved by SCO to provide packetswitched connection Between a master and a slave only a single ACL link can exist
Gives specifications for state transmission mode, supervision, power level monitoring, synchronisation, and exchange of capability, packet flow latency, peak data rate, average data rate, maximum burst size parameters from lower and higher layers
129
Operating System
Developed to use bare machines (hardware) Essential software required to work with a computer Manage basic hardware resources and provide interface to users and their programs Also Controls the execution of application programs
ET-2012
SVBIT,Gandhinagar
132
ET-2012
SVBIT,Gandhinagar
133
Process
Process is a program in execution. It includes current activity as represented by PC, Registers, Stack, etc. Unit of Work in Modern Time Sharing systems
Process A process is sequence of instruction. Process is a dynamic entity, that is a program in execution. Process is active part. During execution it gives the result Process is stored into memory Program Program contains the instruction. Program is static entity made up of program statement. Program is passive part. It doesnt give any result but gives result after starting its execution and becomes process. Program is stored in disk.
ET-2012
Process compete for computing Program does not compete for resources like CPU time or memory.SVBIT,Gandhinagar Computing resources.
134
Process State
As process executes it changes state. State is defined by the current activity of the process.
3.
4.
Blocked/Waiting: Process is waiting for some event to occur e.g. I/O operation finish.
Blocked process cannot be scheduled for running even if CPU is free.
5.
ET-2012
SVBIT,Gandhinagar
135
running
waiting
ET-2012 SVBIT,Gandhinagar 136
Process Definition
Process is that executing unit of computation, which is controlled by some processes of the OS
for a scheduling mechanism that lets it execute on the CPU
for a resource-management mechanism that lets it use the system-memory and other system-resources such as network, file, display or printer for access control mechanism for inter-process communication concurrently
ET-2012
SVBIT,Gandhinagar
138
PCB Contents
Process State: - Information about various process states such as new, ready, running, waiting, etc.
Program Counter: - It shows the address of the next instruction to be executed in the process.
CPU registers: - There are various registers in CPU such as accumulators, stack pointer, working register, instruction pointer. PCB stores the state of all these register when CPU switch from one process to another process.
CPU Scheduling information: - It includes process priority, pointer to the ready queue and device queue, and scheduling information. Accounting information: - It includes total CPU time used, real time used, process number, etc.
I/O status information: - It includes list of I/O device allocated to the process. It also includes the list of opened file by process in disk. File is opened either for read or write.
Memory-management information: - PCB stores the value of base and limit registers, address of page table or segment table, and other memory management information.
SVBIT,Gandhinagar
ET-2012
139
Context Switching
When CPU switch from one process to another process, CPU saves the information about the one process into PCB (Process Control Block) and then starts the new process. The present CPU registers, which include program counter and stack pointer are called context. When context saves on the PCB pointed process-stack and register-save area addresses, then the running process stops.
Other process context now loads and that process runs This means that the context has switched.
Context switch is purely overhead because system does not perform any useful work while context switch.
Context switch times are highly dependent on hardware. Its speed vary from machine to machine depending on the memory speed, registers to be copied and existence of special instructions.
ET-2012 SVBIT,Gandhinagar 140
Thread
Many software that run on desktop PCs are multithreaded. An application typically is implemented as a separate process with several threads of control. A web browser may have one thread display images or text while another thread retrieves data from the network. Another example, a word processor may have a thread for displaying graphics, another thread for reading key stroke from the user, and third thread for performing spelling and grammar checking in the background.
ET-2012 SVBIT,Gandhinagar 141
Thread
A Thread, sometimes called lightweight process (LWP), is basic unit of CPU utilization. Each thread has independent parameters -- a thread ID, a program counter, a register set, and a stack, priority and its present status . A traditional heavyweight Process (a kernel-level controlled entity) has a single thread of control. If the process has multiple threads of control, it can do more than one task at a time.
ET-2012
SVBIT,Gandhinagar
142
Thread
A thread can either be a sub-process within a process (kernel level thread) or a process within an application program (user level thread) Thread states starting, running, blocked (sleep) and finished. A thread does not call another thread to run.
ET-2012
SVBIT,Gandhinagar
143
Process
Process is considered heavy weight
Thread
Unit of Resource Allocation and of protection Process creation is very costly in terms of resources Program executing as process are relatively slow
Thread can access the memory area belonging to another thread within the same process
Thread switching is faster One thread can belong to exactly one process
SVBIT,Gandhinagar 144
Task
Task term used for the process in the RTOS for the embedded systems. An application program consist of the tasks and task behaviors in various states that are controlled by OS. A task is like a process or thread in an OS. Runs when it is scheduled to run by the OS (kernel), which gives the control of the CPU on a task request (system call) or a message. Runs by executing the instructions and the continuous changes of its state takes place as the program counter (PC) changes A task an independent process. No task can call another task.
ET-2012 SVBIT,Gandhinagar 145
Task
Includes task context and TCB TCB A data structure having the information using which the OS controls the process state. Stores in protected memory area of the kernel. Consists of the information about the task state
ET-2012
SVBIT,Gandhinagar
146
Task
TaskID, e.g. a number between 0 and 255 task priority, between 0 and 255, represented by a byte parent task (if any), child task (if any), address to the next tasks TCB of task that will run next
ET-2012
SVBIT,Gandhinagar
147
Task States
1. Idle state [Not attached or not registered] 2. Ready State [Attached or registered] 3. Running state 4. Blocked (waiting) state 5. Delayed for a preset period Number of possible states depends on the RTOS.
ET-2012
SVBIT,Gandhinagar
148
Scheduling
Scheduling implies selection of a process for execution in a way to meet the objective of the system (throughput, response time, etc.) Scheduler is the program responsible for scheduling
ET-2012
SVBIT,Gandhinagar
149
Scheduling Criteria
Turn around Time
Interval of time between submission & completion
Waiting Time
Time spent waiting in ready queue
Response Time
Time from submission until response received
CPU Utilisation
Keep busy
Throughput
Number of process completed per unit time
Fairness
No process should starve
Enforcing Priorities
ET-2012
150
Scheduling Algorithms
Non Preemptive Mode: process would be taken away from the processor if any one of the following events occur
Its completion It requires some I/O It executes a system call 1. FCFS (First Come First Serve) 2. SJF (Shortest Job First) 3. Priority
Preemptive Mode: process would be taken away from the processor if any one of the following events occur
Timeout occurs Arrival of new process with higher priority 1. Round Robin 2. SRT (Shortest Remaining Time) 3. Priority SVBIT,Gandhinagar
ET-2012
151
ET-2012
SVBIT,Gandhinagar
152
FCFS Example
Code is simple to write and understand Convoi effect: large process blocking few smaller processes which degrade the scheduling parameters. Assume Burst time, P1=24, P2=3, P3=3 (in ms) Order P1,P2,P3
P2 waits 24, P3 waits 24+3=27 Average wait = (0+24+27)/3=17ms (AWT or ART) ATAT= ((0+24)+(24+3)+(27+3))/3=27ms
Order P2,P3,P1
P3 waits 3, P1 waits 3+3=6 Average wait = (0+3+6)/3=3ms ATAT= ?
ET-2012 SVBIT,Gandhinagar 153
ET-2012
SVBIT,Gandhinagar
154
Preemptive SJF algorithm Process which requires shortest remaining time would be given first chance for execution. Burst time cannot be determined exactly, it can only be estimated by empirical formula
ET-2012
SVBIT,Gandhinagar
155
ET-2012
SVBIT,Gandhinagar
157
Process having highest priority would be scheduled for execution first Equal Priorities scheduled in FCFS Internal Priorities
Time limit Memory requirement Number of open files
External Priorities
ET-2012
158
Scheduling Examples
AWT = 8.2 Drawback: In heavily loaded system, continuous stream of higher priority processes will keep the lower priority process from getting access to the CPU. Solution: Aging technique of gradually increasing the priority of the process waiting in the queue
ET-2012 SVBIT,Gandhinagar 159
Principles of Concurrency
Three contexts: Multiple applications: Multiprogramming was invented to allow the processing time of the computer to be dynamically shared among a number of active jobs
Structured application: As an extension of principles of modular design and structured programming , some application can be effectively implemented as a set of concurrent process Operating System Structure: The same structuring advantages apply to the systems programmer and some OS are themselves implemented as a set of processes.
ET-2012 SVBIT,Gandhinagar 160
In multiple processor system, it is possible not only to interleave processes but to overlap them. (b)
ET-2012
SVBIT,Gandhinagar
161
Process Interaction
Independent Process(Unaware of each other)
If it cant affect or cant be affected by another process executing in the system No data sharing with another process in system
Cooperative Process
If it can affect or can be affected by another process executing in the system
1. Cooperation by Sharing (access to some common object) Indirectly Aware 2. Cooperation by Communication Directly Aware
ET-2012
SVBIT,Gandhinagar
162
2. Progress
If there is no process inside critical section then AND if a process wants to enter critical section then it should not be stopped by another process.
3. Bounded Waiting
There exist a limit on the number of times the other process should be allowed to enter the critical section after a process has requested for the same. Decision of entering critical section should not be postponed indefinitely.
2.
3. 4.
A process that halts in its non-critical section must do so without interfering with other processes.
It must not be possible for a process requiring access to critical section to be delayed indefinitely: no deadlock or starvation When no process is in a critical section, any process that request entry into critical section must be permitted to enter without delay
5.
6.
ET-2012
Queue to communicate data Mailbox/Messages Pipes and Sockets Semaphores to trigger actions Signals Remote Procedure Call (RPC) for distributed systems
SVBIT,Gandhinagar 166
Semaphore
Programming language concept proposed for IPC Two elements count and queue
Count is always initialized to non-negative value WAIT operation decrements the semaphore value. If negative then process that executed wait would get blocked.
To receive a signal by semaphore, a process executes the primitive wait(s)
3.
SIGNAL operation increments the semaphore. If not positive then semaphore will unblock one of the process from its queue and that process to ready queue.
To transmit a signal by semaphore, a process executes the primitive signal(s)
SVBIT,Gandhinagar 167
ET-2012
Semaphore
Other than these three operations there is no way to inspect or manipulate semaphore Wait and Signal primitives are assumed to be atomic i.e. they cannot be interrupted and each routine can be treated as indivisible step. P (for wait operation) derived from a Dutch word Proberen, which means 'to test'. P semaphore function signals that the task requires a resource and if not available waits for it.
V (for signal passing operation) derived from the word 'Verhogen' which means 'to increment'. V semaphore function signals which the task passes to the OS that the resource is now free for the other users. Semaphore are used to count the number of wakeups saved or some positive value then one or more wakeups are pending
For any semaphore a queue is used to hold processes waiting on the semaphore.
ET-2012 SVBIT,Gandhinagar 168
Semaphore
General semaphore (Counting or P-V semaphore)
Count can take any integer value Used for process synchronisation
Strong semaphore
Queue implemented as FIFO queue
The process blocked longest would be released first
Weak semaphore
Queue implemented as priority queue May suffer from starvation
ET-2012 SVBIT,Gandhinagar 169
Mutex Semaphore
Mutex means mutually exclusive key Mutex is a binary semaphore usable for protecting use of resource by other task section at an instance Let the key sm initial value = 1 When the key is taken by section the key sm decrements from 1 to 0 and the waiting task codes starts. Assume that the sm increments from 0 to 1 for signaling or notifying end of use of the key that section of codes in the task or thread. When sm = 0 > assumed that it has been taken (or accepted) and other task code section has not taken it yet and using the resource When sm = 1 > assumed that it has been released (or sent or posted) and other task code section can now take the key and use the resource
ET-2012 SVBIT,Gandhinagar 170
Signal
A signal is the software equivalent of the flag at a register that sets on a hardware interrupt. Unless masked by a signal mask, the signal allows the execution of the signal handling function and allows the handler to run just as a hardware interrupt allows the execution of an ISR Signal is a one/two byte IPC used for signaling from a process to OS (to enable start of another process) A provision for interrupt-message from a process or task to another process or task When the IPC functions for signal are not provided by an OS, then the OS employs semaphore for the same purpose.
ET-2012 SVBIT,Gandhinagar 171
6.
7. 8.
1. 2.
ET-2012
Queue
Every OS provides queue IPC functions for inserting and deleting the message-pointers or messages in FIFO or priority mode.
Each queue for a message need initialization (creation) before using the functions in the scheduler for the message queue.
Each queue either has a user definable size (upper limit for number of bytes) or a fixed pre-defined size assigned by the scheduler. When a queue becomes full, there may be a need for error handling and user codes for blocking the task(s). There may not be self-blocking. Queue functions: Create, Post, PostFront, Pend, Flush, Query, Accept, and Delete
ET-2012 SVBIT,Gandhinagar 173
Mailbox
Mailbox (for message) is an IPC through a message-block at an OS that can be used only by a single destined task. Each mailbox usually has one message pointer only, which can point to message. OS mailbox functions: Create, Query, Post, Pend, Accept, Delete
ET-2012
SVBIT,Gandhinagar
174
Pipe
Pipe is a device used for the inter process communication. Pipe has the functions create, connect and delete and functions similar to a device driver (open, write, read, close)
A message-pipe a device for inserting (writing) and deleting (reading) from that between two given inter-connected tasks or two sets of tasks.
Pipes are also like Java IO stream. In a pipe there may be no fixed number of bytes per message with an initial pointer for the back and front. Pipe is unidirectional.
A pipe could be used for inserting the byte steam by a process and deleting the bytes from the stream by another process.
ET-2012 SVBIT,Gandhinagar 175
Socket
Socket Provides for a bi-directional pipe like device, which also use a protocol between source and destination processes for transferring the bytes. Provides for establishing and closing a connection between source and destination processes using a protocol for transferring the bytes.
Two tasks at two distinct places or locally interconnect through the sockets.
Multiple tasks at multiple distinct places interconnect through the sockets to a socket at a server process. The client and server sockets can run on same CPU or at distant CPUs on the Internet.
ET-2012
176
Socket
Socket is used for IPC and also for communication of process in network. A socket is created by the socket system call, which returns a descriptor for it. it is logical connection for communication &
support various communication semantics. Socket does not, it exists as long as some
process holds a descriptor referring to it. Socket when named, is called Port.
unidirectional. Piping is a process where the o/p of one process is made the i/p of another
ET-2012
SVBIT,Gandhinagar
Queue
Message queue is managed by kernel. All the queue memory allocated at creation. Message queue is a method by which process can pass data using an interface. A message queue can be created by one process and used by multiple processes that read / write messages to the queue Queue is not a streaming interface.
Pipe is a technique for passing information from one process to another Two processes, one feeding the pipe with data while the other extracts the data at the other end. Pipe is a linear array of bytes, as is a file, but it is used solely as an I/O stream.
Pipe supports destructive reading. (once if Datagram-like behavior: reading an entry you read it vanishes) removes it from the queue. If you don't read the entire data, the rest is lost Pipe is one-way communication only Have a maximum number of elements and each element has maximum size
ET-2012
SVBIT,Gandhinagar
178
Topics
1. Operating System Services
a. GOAL, b. MODES AND c. STRUCTURE
A kernel can be contrasted with a shell, the outermost part of an operating system that interacts with user commands.
Kernel and shell are terms used more frequently in Unix operating systems than in IBM mainframe or Microsoft Windows systems.
Process Creation
Step 1: At the reset of the processor. in a computer system, an OS is initialized first enabling the use of the OS functions, which includes the function to create the processes. Step 2: Using OS process creation function, a process, which can be called initial process, is created. Step 3: OS started and that calls the initial process to run.
Step 4: When the initial process runs, it creates subsequent processes. Processes can be created hierarchically. OS schedules the threads and provide for context switching between the threads (or tasks).
Creation of a process
Means defining the resources for the process and address spaces (memory blocks) for the created process, its stack, its data and placing the process initial information at a PCB(Process Control Block), or TCB(Task Control Block)
2. Display_BatteryThread
3. Display_SignalThread 4. Display_ProfileThread 5. Display_MessageThread
6. Display_Call StatusThread
7. Display_MenuThread
Memory Management
Memory allocation
When a process is created, the memory manager allocates the memory addresses (blocks) to it by mapping the process address space. Threads of a process share the memory space of the process
Topics
Basic OS Functions
Process Management,(done) Memory Management(done) Device Management(SS) I/O Device Management(SS)
Scheduling
Definition: It is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). By use of Proper algorithm of scheduling, we can perform multiple task in a given time. The scheduler is concerned mainly with: Throughput - The total number of processes that complete their execution per time unit. Response time - amount of time it takes from when a request was submitted until the first response is produced. Waiting Time - Equal CPU time to each process (or more generally appropriate times according to each process' priority). It is the time for which the process remains in the ready queue.
215
1.
Dis-advantages:
Longer execution time of a low priority task makes a higher priority task wait until it finishes.
2.
Cyclic Scheduling
Example
Tasks programs contexts at the five instances in the Time Scheduling Scheduler for C1 to C5
Priority-based Scheduling
Typical RTOS based on fixed-priority preemptive scheduler
Time Period
1 P1 2 P2 3 P3
Scheduling P2
P1
P1
P2 P3
P1
P3
After completing other high priority process, switch to next interrupted low priority process
RMS Scheduling
Rate-Monotonic Scheduling
The utilization bound (UB) test allows schedulability analysis by comparing the calculated utilization for a set of tasks and comparing that total to the theoretical utilization for that number of tasks:
If this equality is satisfied, all of the tasks will always meet their deadlines. If the total utilization calculates to greater than 100%, the system will have scheduling problems.
100%
82.8% 78.0% 75.7% 74.3% 71.8%
P1 P2 P3
4 6 12
And Time period P1 process = 4 secs. Means P1 repeat after every 4 secs
Solution:
Golden Rule : 1. Shortest test period = Highest Priority 2. Check for Schedulability
1.
P2
P3
2.
2
3
6
12
Medium(2)
Low(3)
Here U(n) < 1, so we can schedule the process by using RMS scheduling algorithm
Processes P1 P2 P3
Time Period 4 6 12
Processes
P3 P3
P3
P2
P2
P1
P1
10
11
12
P1 P2 P3
4 6 12
Solution Here clearly the CPU Utilization is more than 1 (i.e. 1.25). So these is not Scheduled.
P1 P2 P3
3 4 5
Solution Step 1: Check for Schedulability U = 1/3 + 1/4 + 2/5 = 0.98 which is less than 1 So we can schedule the given task
Solutions
Period (UPTO 60)
1 2 3
d(1)
Processes
P1 P2 P3
4
d(2)
5
d(3)
6
d(1)
8
d(2)
9
d(1)
10
d(3)
11
12
d(1) d(2)
13
14
15
d(1) d(3)
16
P1
P2
P3
P3
P1
P2
P1
P3
P1
P2
P1
P3
P3