• No results found

rts 3

N/A
N/A
Protected

Academic year: 2021

Share "rts 3"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

ASSIGNMENT 3

ASSIGNMENT 3

RE AL TIME SYSTEM AND SOFTWARE

RE AL TIME SYSTEM AND SOFTWARE

Submitted

Submitted To–

To–

Submitte

Submitted

d By-

By-L

Leecctt.

. G

Ga

arrg

gi

i S

Sh

ha

arrm

ma

a

S

Su

urreen

nd

drra

a

MCA 4

MCA 4

thth

SEM

SEM

D3804A15

D3804A15

10806601

10806601

Declaration: Declaration:

I declare that this assignment is my individual work. I have not

I declare that this assignment is my individual work. I have not

copied from any other student’s work or from any other source

copied from any other student’s work or from any other source

except where due acknowledgment is made

except where due acknowledgment is made explicitly in the

explicitly in the

text, nor has any part been written for me by another person.

text, nor has any part been written for me by another person.

Student’s

Student’s

Signature:

Signature:

surendra

surendra

Evaluator’s comments:

Evaluator’s comments:

 ________________________________________________________________ 

 ________________________________________________________________ 

 _____ 

 _____ 

Marks obtained: ___________ out of ______________________ 

Marks obtained: ___________ out of ______________________ 

Content of Homework should start from this page only: Content of Homework should start from this page only:

(2)

Part-A Part-A

1.

1. Explain using an appropriate example as to why a critical resourceExplain using an appropriate example as to why a critical resource can get corrupted if the task using it is pre-empted, and then another can get corrupted if the task using it is pre-empted, and then another task is granted use of resources.

task is granted use of resources. Answer:

Answer: In many applications, real time tasks need to share someIn many applications, real time tasks need to share some resources among themselves. The task that is using a resource, can not resources among themselves. The task that is using a resource, can not immediately hand over the resource to another task that requests the immediately hand over the resource to another task that requests the resource at any arbitrary point in time; but it can do so only after it resource at any arbitrary point in time; but it can do so only after it completes its use of the resource. If a task is pre-empted before it completes its use of the resource. If a task is pre-empted before it

completes using the resource, then the resource can become corrupted. completes using the resource, then the resource can become corrupted. Examples of such resources are files, devices and certain data structures. Examples of such resources are files, devices and certain data structures. Sharing of resources among tasks requires a different set of rules,

Sharing of resources among tasks requires a different set of rules,

compared to the rules used for sharing resources such as a CPU among compared to the rules used for sharing resources such as a CPU among tasks. CPU is a serially reusable resource. So that two different tasks tasks. CPU is a serially reusable resource. So that two different tasks cannot run on a CPU at the same time. An executing task can be cannot run on a CPU at the same time. An executing task can be  preempted and restarted at a later time without any problem.  preempted and restarted at a later time without any problem.

2.

2. Define Define the term pthe term prioririority invety inversion anrsion and unbound unbounded prided priority iority inversinversionon as used in real time operating systems. Is it possible to device a

as used in real time operating systems. Is it possible to device a resource sharing protocol which can guarantee that no task  resource sharing protocol which can guarantee that no task 

undergoes: (i) Priority inversion (ii) unbounded priority inversion. undergoes: (i) Priority inversion (ii) unbounded priority inversion. Justify your answer?

Justify your answer? ANSWER:

ANSWER:

The

The priority inversionpriority inversion is the state when a lower priority task is holdingis the state when a lower priority task is holding

resource and the higher priority task needs that resource which is already held resource and the higher priority task needs that resource which is already held  by lower priority task. Then the higher priority task waiting until the resource is  by lower priority task. Then the higher priority task waiting until the resource is

not released by lower

not released by lower priority task. priority task. So the higher priority So the higher priority task is gone to task is gone to under under   priority inversion. That’s the simple priority inversion.

 priority inversion. That’s the simple priority inversion. The

The unbounded priority inversionunbounded priority inversion is that when some intermediate prioris that when some intermediate priority task ity task  are comes and usage the CPU, they don’t need the resource. The intermediate are comes and usage the CPU, they don’t need the resource. The intermediate task are executed and then the lower priority task is using the resources and task are executed and then the lower priority task is using the resources and higher priority task is waits for releasing the resource then the higher priority higher priority task is waits for releasing the resource then the higher priority

(3)

task is gone under the unbounded priority inversion. task is gone under the unbounded priority inversion.

There is TH is higher priority task and TL is lower priority task and holding the There is TH is higher priority task and TL is lower priority task and holding the resource R. Then the intermediate tasks T11, T12, T13... so on are come and resource R. Then the intermediate tasks T11, T12, T13... so on are come and use the CPU and they don’t need the resource. So the TH is waits the

use the CPU and they don’t need the resource. So the TH is waits the

intermediate task and lower priority task. Then the TH is gone under unbound intermediate task and lower priority task. Then the TH is gone under unbound  priority inversion.

 priority inversion.

 The simplest way to avoid the priority inversion is to prevent pre-The simplest way to avoid the priority inversion is to prevent

pre-emption (from CPU usage) of lower priority task holding a critical emption (from CPU usage) of lower priority task holding a critical resource by intermediate priority task.

resource by intermediate priority task.

 This task can be done by increasing the priority level of the lower This task can be done by increasing the priority level of the lower   priority task to be equal to that of the waiting higher priority task.  priority task to be equal to that of the waiting higher priority task.

 The means is that the lower priority tasks inherit the priority of theThe means is that the lower priority tasks inherit the priority of the higher priority task.

(4)

In the above figure scenario 1 the Ti task is holding a critical resource and the In the above figure scenario 1 the Ti task is holding a critical resource and the  priority is 5.

 priority is 5.

In the scenario 2 the other task Tj is requesting the resource and its priority is In the scenario 2 the other task Tj is requesting the resource and its priority is 10.

10.

Then the ti is inheriting the priority of Tj in scenario 3. Then the ti is inheriting the priority of Tj in scenario 3.

In scenario 4 the ti completed its task and Tj holds the resource. In scenario 4 the ti completed its task and Tj holds the resource. So there is no priority inversion.

So there is no priority inversion.

3.

3. Why it is Why it is necessnecessary to syncary to synchronizhronize the cloce the clocks in a diks in a distribustributed real tted real timeime systems?

systems? Discuss the Discuss the relative advantage relative advantage and disadvantage and disadvantage of theof the centralized and distributed clock synchronization scheme?

centralized and distributed clock synchronization scheme? ANSWER:

ANSWER: The reason of synchronize the clocks in a distributed real timeThe reason of synchronize the clocks in a distributed real time systems is that the lake of the synchrony and drift among clocks makes the systems is that the lake of the synchrony and drift among clocks makes the time stamping and timeout operation in distributed

time stamping and timeout operation in distributed real time systemreal time system meaningless. Therefore, to have

meaningless. Therefore, to have meaningful timeout and time stampingmeaningful timeout and time stamping spanning more than one node of distributed system, the clock needs to be spanning more than one node of distributed system, the clock needs to be synchronised.

synchronised.

Centralized clock synchronization scheme advantages: Centralized clock synchronization scheme advantages:

In the centralized clock one is the master clock and other connected clocks In the centralized clock one is the master clock and other connected clocks are slave clock. The master clock is connected to every slave clocks. So the are slave clock. The master clock is connected to every slave clocks. So the master clock is having all information regarding the slave clock.

(5)

Centralized clock synchronization scheme disadvantages: Centralized clock synchronization scheme disadvantages:

There is a problem if slave clocks are wants to share information with other  There is a problem if slave clocks are wants to share information with other  slave clocks. The cost of centralized clock is high.

slave clocks. The cost of centralized clock is high.

Distributed clock synchronization scheme advantages: Distributed clock synchronization scheme advantages:

These systems allow the sharing of information and resources over a wide These systems allow the sharing of information and resources over a wide

geographic spread and are usually better than traditional centralized systems in geographic spread and are usually better than traditional centralized systems in terms of sharing, cost, growth and autonomy.

terms of sharing, cost, growth and autonomy.

Distributed clock synchronization scheme disadvantages: Distributed clock synchronization scheme disadvantages:

The distributed nature of these systems has to cope with unreliable and insecure The distributed nature of these systems has to cope with unreliable and insecure communications and independent failures. These problems become aggravated communications and independent failures. These problems become aggravated when the system is operating critical real time applications such as aerospace when the system is operating critical real time applications such as aerospace systems, life support systems, nuclear power plants, drive-by-wire systems and systems, life support systems, nuclear power plants, drive-by-wire systems and computer-integrated manufacturing systems. Common to all

computer-integrated manufacturing systems. Common to all these applicationsthese applications is the demand for maximum reliability and high performance from computer  is the demand for maximum reliability and high performance from computer 

(6)

controllers, since a single controller failure in these applications can lead to controllers, since a single controller failure in these applications can lead to disaster.

disaster.

Part-B Part-B 4.

4. ExplaExplain why ain why algoritlgorithms that chms that can be satian be satisfactosfactorily usrily used to scheed to schedule readule reall time tasks on multi processor s often are not satisfactory to schedule time tasks on multi processor s often are not satisfactory to schedule real time tasks on distributed systems, and vice versa?

real time tasks on distributed systems, and vice versa? ANSWER:

ANSWER:

These are following four properties that scalable real-time kernels for function These are following four properties that scalable real-time kernels for function distribute

distributed multiprocessors are required d multiprocessors are required to satisfy.to satisfy.

(A) The maximum execution time of an operation that is to synchronize or  (A) The maximum execution time of an operation that is to synchronize or  communicate with tasks on the same processor (called a local operation) can be communicate with tasks on the same processor (called a local operation) can be determined independently of the other processors' activities and the number of  determined independently of the other processors' activities and the number of  contending processors.

contending processors.

(B) The maximum execution time of an operation that is to synchronize or  (B) The maximum execution time of an operation that is to synchronize or 

communicate with tasks on other processors can be determined independently of  communicate with tasks on other processors can be determined independently of  the other processors' activities and be bounded with a linear order of the number of  the other processors' activities and be bounded with a linear order of the number of  contending processors.

contending processors.

(C) The maximum interrupt response time on each processor can be determined (C) The maximum interrupt response time on each processor can be determined independently of the other processors' activities and the number of contending independently of the other processors' activities and the number of contending  processors.

 processors.

(D) The interrupt service overhead can be determined independently of the other  (D) The interrupt service overhead can be determined independently of the other   processors' activities and the number of contending processors.

 processors' activities and the number of contending processors.

5.

5. ExplaExplain the tiin the time servme services that a rices that a real timeal time operatie operating system ng system (RTOS(RTOS) is) is expected to support. Also briefly highlight how timer services are expected to support. Also briefly highlight how timer services are implemented in a real time operating system?

implemented in a real time operating system? ANSWER:

ANSWER:

The time services provided by an operating system are based on a software The time services provided by an operating system are based on a software clock called the system clock maintained by the operating system. The system clock called the system clock maintained by the operating system. The system clock is maintained by the kernel based on the interrupts received from the clock is maintained by the kernel based on the interrupts received from the hardware clock. Since hard real-time systems usually have timing constraints in hardware clock. Since hard real-time systems usually have timing constraints in

(7)

th

the e mimicrcro o sesecocondnds s rarangenge, , ththe e sysyststem em clclocock k shshouould ld hahave ve susufffficicieientntly ly fifinene resolu

resolution1 to tion1 to support the necessary time services. However, designers of support the necessary time services. However, designers of real- real-time operating systems find it very difficult to support very fine resolution time operating systems find it very difficult to support very fine resolution system clocks.

system clocks.

In current technology, the resolution of hardware clocks is usually finer than In current technology, the resolution of hardware clocks is usually finer than a nanosecond (contemporary processor speeds exceed 3GHz). But, the clock  a nanosecond (contemporary processor speeds exceed 3GHz). But, the clock  resolution being made available by modern real-time operating systems to the resolution being made available by modern real-time operating systems to the  programmers is of the order of several milliseconds or worse.

 programmers is of the order of several milliseconds or worse. The

The hardwahardware re clock periodicaclock periodically generates interrupts (often called lly generates interrupts (often called time servicetime service interrupts). After each clock interrupt, the kernel updates the software clock and interrupts). After each clock interrupt, the kernel updates the software clock and also performs certain other work.

also performs certain other work.

6.

6. Briefly explain why the traditional UNIX kernel is not suitable to beBriefly explain why the traditional UNIX kernel is not suitable to be

used in a multiprocessor environment. Explain a spin lock and a used in a multiprocessor environment. Explain a spin lock and a kernel level lock and discuss their use in realization a pre-emptive kernel level lock and discuss their use in realization a pre-emptive kernel.

kernel. Answer:

Answer: One of the biggest problems that real-time programmers face whileOne of the biggest problems that real-time programmers face while using UNIX for real-time application development is that UNIX kernel cannot using UNIX for real-time application development is that UNIX kernel cannot  be preempted. That is, all interrupts are disabled when any operating system  be preempted. That is, all interrupts are disabled when any operating system

routine runs. routine runs.

Let us elaborate this issue. Let us elaborate this issue.

Application programs invoke operating system services through system calls. Application programs invoke operating system services through system calls. Examples of system calls include the operating system services for creating a Examples of system calls include the operating system services for creating a  process, interprocess communication, I/O operations, etc. After a system call is  process, interprocess communication, I/O operations, etc. After a system call is

invoked by an application, the ar

invoked by an application, the arguments given by the application whileguments given by the application while

invoking the system call are checked. Next, a special instruction called a trap invoking the system call are checked. Next, a special instruction called a trap (or a software interrupt) is executed. As soon as the trap instruction is executed, (or a software interrupt) is executed. As soon as the trap instruction is executed, the handler routine changes the processor state from user mode to kernel mode the handler routine changes the processor state from user mode to kernel mode (or supervisor mode), and the execution of the required kernel routine starts. (or supervisor mode), and the execution of the required kernel routine starts.

(8)

SPIN LOCK AND A KERNEL LEVEL LOCK:

SPIN LOCK AND A KERNEL LEVEL LOCK:

The most common locking primitive in the kernel is t

The most common locking primitive in the kernel is the spinlock, defined inhe spinlock, defined in include/asm/spinlock.h and include/Linux/spinlock.

include/asm/spinlock.h and include/Linux/spinlock.h. The spinlock h. The spinlock is ais a  very simple single-holder lock. If a process

 very simple single-holder lock. If a process attempts to acquire a spinlock attempts to acquire a spinlock  and it is unavailable, the process will

and it is unavailable, the process will keep trying (spinning) until it cankeep trying (spinning) until it can acquire the lock. This simplicity creates a small and fast

acquire the lock. This simplicity creates a small and fast lock.lock. Note that spinlocks in Linux are not

Note that spinlocks in Linux are not recursive as they may be in otherrecursive as they may be in other operating systems.

operating systems. Spinlocks should be Spinlocks should be used to lock data used to lock data in situationsin situations  where the lock is not

 where the lock is not held for a long time—recall that held for a long time—recall that a waiting process willa waiting process will spin, doing nothing, waiting for the

spin, doing nothing, waiting for the lock.lock.

The kernel is

The kernel is a highly multithreaded environment. Unless some data structurea highly multithreaded environment. Unless some data structure is private to a single thread of context you have to do appropriate locking for it. is private to a single thread of context you have to do appropriate locking for it.

A spin lock is used as an underlying synchronization primitive to guard the queue A spin lock is used as an underlying synchronization primitive to guard the queue of tasks that are waiting to enter an application-level critical section. Another  of tasks that are waiting to enter an application-level critical section. Another  queue (called a ready queue) of the tasks that are ready to execute on a processor  queue (called a ready queue) of the tasks that are ready to execute on a processor  should also be guarded with a spin lock. Those queues of tasks are shared among should also be guarded with a spin lock. Those queues of tasks are shared among  processors and thus must be accessed exclusively by a processor within the  processors and thus must be accessed exclusively by a processor within the

run-time system. time system.

It is ideal from the scalability point of view that the worst-case execution time of  It is ideal from the scalability point of view that the worst-case execution time of  each run-time system service

(9)

References

Related documents

Connect the Yellow wire from the t-harness to the Yellow wire on the EVO 20-pin plug AND the Pink wire in the remote start’s power harness.. You will not be using any more of the

This result suggests to us that the observed differences in risk aversion in the lottery task could be rationalized by the effects of background wealth on consumption, if the

On average, families with one or more underinsured adults aged 18 to 64 spent an average of $4,449.19 out of pocket for medical expenses in the 12 months prior to the 2009 survey 7

3.- Assessment of the efficiency of biogas production in small anaerobic digesters and treatment of digestates using an anaerobic thermophilic process of short duration in

Classification using Adaptive Dictionary Learning The class specific dictionaries are learned using training data of the corresponding class [14].. The subsections below de-

In particular, the factors recombinant human Bone Morphoge- netic Protein-2 (rhBMP-2) [4—7] and recombinant human Platelet-Derived Growth Factor (rhPDGF) [8—10] have been shown

Following this idea, for proper biofilm removal in food related surfaces as well as in others capable of harbour bacterial biofilms, customised treatments depending on the

• Priority based scheduling: highest priority task is executed. • Designed for