APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : SEMESTER 6

Subject : Embedded System

Year : 2018

Term : MARCH

Scheme : 2015 Full Time

Course Code : EC 308

Page:58





PDF Text (Beta):

تت

2
7.11 SEMAPHORE எனககக ടി പിത്തത്തെ

The OS provides for semaphore as notice or token for an event occurrence. Semaphore facilitates IPC ௩

1179 task section change to the running state upon event ‏إن‎
‎notifyi rough a scheduler) a waiting task section 6 ⋅ യിര; Preseny
னை भ 7 3 or task. A semaphore as binary semaphore is a token OF സാധം be
running 7 = 77.2). The OS also provides for mutex access to a set of codes 10 8 task (or threag ४
ண்‌, Sections 7 2 ஹாம்‌ 7.8.3). The use of mutex is such that the priority inversion problem is not Solved
५५ 0 ‏کا‎ 7 7 ∙∙⋅

⋅ ரானை OSes. The OS also provides for counting semaphores. The 06
in some OSes while it is solved in other hich can be used for notifying event occurrence a ಕೆ

vide 1 standard P and V semaphores w റ ಜತ
agi ‏کا‎ coming The timeout can be defined in the argument with wait function ೦೯ the semaphore IPc.
The error pointer can also be defined in the arguments for semaphore IPC functions.
The following are the functions, which are generally provided in an OS, for example, ൮05. for the

semaphores.

1. OSSemCreate, a semaphore function to create the semaphore in an event control block (ECB). Initialize

it with an initial value. ವ

೧590717051, a function which sends the semaphore notification to ECB and its value increments 00

event occurrence (used in ISRs as well as tasks).

3. OSSemPend, a function, which waits the semaphore from an event, and its value decrements on taking
note of that event occurrence (used in tasks not in ISRs).

4. OSSemAccept, a function, which reads and returns the present semaphore value and if it shows
occurrence of an event (by non-zero value) then it takes note of that and decrements that value (no
wait; used in ISRs as well as tasks).

5. OSSemQuery, a function, which queries the semaphore for an event occurrence or non-occurrence by
reading its value and returns the present semaphore value, and returns pointer to the data structure
OSSemData. The semaphore value does not decrease. The OSSemData points to the present value
and table of the tasks waiting for the semaphore (used in tasks).

2.

An OS provides the IPC functions create, post, pend, accept and query for using semaphores. The time-out
can be provided with ‘pend" function arguments. A pointer to error-handling function can also be specified
in the arguments.

7.11.1 Mutex, Lock and Spin Lock

An OS, using a mutex blocks a critical section in a task on taking the mutex by another task’s critical section.
Other task unlocks on releasing the mutex. The mutex wait by blocked task can be for a specified timeout.
There is a function in kernel called lock ( ). It locks a process to the resources till that process executes unlock
( ). A wait loop creates and when wait is over the other processes waiting for the lock starts. Use of lock ( ) and
unlock ( ) involves little overhead compared to uses of OSSemPend ( ) and 1٤۱
when using a mutex. Overhead means number of operations needed for blocking one process and starting
another. However, 6 resource of high priority should not lock the other processes by blocking a
already running task in the following situation. Suppose a task is running and a little time is left for its completio®-
The running time left for it is less compared with the time that would be taken in blocking ॥
and context switching. There is an innovative concept of spin locking in certain OS schedulers. A ۷
15 4 powerful tool in the situation described before, [Refer to ‘Multithreaded Programming with 10४ 0)

Similar Question Papers