Welcome to electrical and electronics engineering Q&A site...

Welcome to electrical and electronics engineering discussion website, Please login or register to continue.

Join our WhatsApp group

Subscribe To Our YouTube Channel

49 views
in Embedded System Design by

Amazon Shopping

Please log in or register to answer this question.

1 Answer

0 votes
by

A semaphore is called binary semaphore when its value is 0, it is assumed that it has been taken (or accepted) & when its value is 1, it is assumed that it has been released & no task has taken it yet.
An ISR can release the token. A task can release the token as well accept the token or wait for taking the token.

Shared data problem solutions:

One solution is atomic queue operation for solving the shared data problem.
1.Use modifier volatile with a declaration for a variable that returns from the interrupt. This declaration warns the compiler that certain variables can modify because the ISR does not consider the fact that the variable is also shared with a calling function.
2.Use reentrant functions with atomic function instructions in that part of a junction that needs its complete execution before it can be interrupted.
3.Put a shared in a critical queue. A function that requires the value of this variable always deletes it from the queue front, and another function, which inserts the value of this variable. always does so at the queue back.
4.Disable the interrupts before a critical section starts executing & enable the interrupts on its completion it is a powerful drastic option. An interrupt even is of higher priority than the present critical function gets disabled.

Shared-Data Problems
Void Task1 (void)
{
:
vconterErrors(9);
:
}
void Task2 (void)
{
:
vcontErrors(11);
:
}
static int cErrors;

void vconutErrors (int vNewErrors)
{
cErrors += cNewErrors:
}

Fig. Tasks can share code

The above fig shows a bug in the code. Here both task1 and task2 call vcontErrors. This is a perfectly valid thing to do in an RTOS. Any or all of the tasks can share as many subroutines as is convenient.
The difficulty with the program is that because both Task1 and Task2 call vcontErrors and since vcontErrors uses the variable cErrors is now shared by the 2 tasks.
If task1 calls vcontErrors, and if the RTOS then stops Task1 and runs Task2 which then calls vcontErrors, the variable cErrors may get corrupted in just the same way as it would if Task2 were an interrupt routine that had interrupted Task1.

Reentrancy:
Reentrant functions are functions that can be called by more than one task and that will always work correctly, even if the RTOS switches from one task to another in the middle of executing the function.
The 3 rules to decide if a function is reentrant are:
1. A reentrant function may not use variables in a nonatomic way unless they are stored on the stack of the task that called the function or are otherwise the private variables of that task that called the function or are otherwise the private variables of that task.
2. A reentrant function may not call any other functions that are not themselves reentrant.
3. A reentrant function may does not use the hardware in a nonatomic way.

Amazon Shopping

Welcome to Q&A site for electrical and electronics engineering discussion for diploma, B.E./B.Tech, M.E./M.Tech, & PhD study.
If you have a new question please ask in English.
If you want to help this community answer these questions.

Categories

Most popular tags

power motor dc circuit transformer voltage current used system phase factor resistance load synchronous energy ac induction generator electric series frequency capacitor use speed between electrical meter line type mosfet control transmission difference magnetic plant high single instrument bjt source advantages function diode machine unit winding torque amplifier define supply thyristor motors arduino field shunt maximum relay armature problem electricity time parallel on transformers types coil diagram state flow value material three starting and direction theorem method emf operating digital microprocessor test instruments efficiency ratio loss measure operation connected low applications wave effect single-phase working losses different network wattmeter temperature measuring constant signal controlled breaker device full compare drive wire resistivity logic materials machines inductance switch flux disadvantages converter transistor gain protection scr angle force core measurement number free principle rc generators law negative bridge friction open circuits pole conductor conservation steam iron loop resistors hysteresis short computer using lines secondary station battery rectifier inverter linear relays nuclear regulation reactance design analog work rotor electronics gate forces diesel damping rlc connection factors capacitors minimum insulation basic moving running systems air fault range direct main stability quality starter igbt eddy ideal ammeter rl 3-phase plants arc induced thermal error fuzzy biasing dielectric pressure balanced superposition errors rotation characteristics feedback measured electronic start alternator off back curve over solar three-phase tariff locomotive peak bias zener capacitance commutator surge rating universal potentiometer permanent mechanical copper self transducer capacity electrons memory adc excitation inductive transfer explain fuse pure harmonics application inductor internal pmmc average reaction welding resonance traction breakers designed electromagnetic si generation brushes density switching shaded rate impedance distribution methods star oscillator reluctance semiconductor simplification algebra 8085 boolean weston dynamometer insulating strength installation permeability definition fuel heating earth units neutral rms rated engineering conductors coefficient controller usually reverse excited analysis change body components
...