1 Answer

Answer :

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.

Related questions

Description : What are counting semaphores and resource semaphore?

Last Answer : If a task tries to take the semaphore when the integer is equal to zero, then the task will block. These semaphores are called counting semaphore. Some system offer semaphore that can be ... , but they cannot be used to communicate between two tasks. Such semaphores are called resource semaphore.

Last Answer : Common computation models: Sequential program model Statements, rules for composing statements, semantics for executing them Communicating process model ... Object-oriented model For breaking complex software into simpler, well-defined pieces

Last Answer : Various features of Linux that are used in embedded systems are as follows : Linux is multiuser operating system. Linux is open source and free. Linux can be ... Linux supports handling of errors. Real-time Linux supports the group scheduling functions.

Last Answer : Liquid Crystal Display:-An LCD is a low-cost, low power device capable of displaying text and images. LCD's are extremely common in embedded systems since such system often does not have video monitors ... toggles the enables bit and acts as a delay so that the command can be processed and executed.

Last Answer : The main characteristics of an embedded system are:1. Single functioned2. Tightly constrained3. Reactive and real time1. Single functioned:An embedded system usually executes a specific program repeatedly.Ex. Pager ... computer user. But it doesn't result in a system failure.Ex. Digital camera chip

Description : Define embedded system.

Last Answer : An embedded system is nearly any computing system other than a desktop computer. Embedded systems are hard to define because they cover such a broad range of electronic devices. It has three main components: 1. Hardware 2. Main application software 3. Real time operating system

Description : What is meant by embedded Linux?

Last Answer : Linux is the operating system if we use this operating system in embedded system devices then it is known as embedded Linux. Linux is open source and free.

Last Answer : Shared memory :For sharing of data faster and communication between programs, we use shared memory. Shared memory can be used with multiprocessors and single processors. Means Program ... No resource preemption4. Circular waitIf the four conditions occur simultaneously then the deadlock occurs.

Description : There are three processes P1, P2 and P3 sharing a semaphore for synchronising a variable. Initial value of semaphore is one. Assume that negative value of semaphore tells us how many processes are waiting in queue. Processes access ... The final value of semaphore will be: (1) 0 (2) 1 (3) -1 (4) -2 

Last Answer : Answer: 1

Description : What does AAA’ stands for in Semaphore?

Description : What is a semaphore? 

Last Answer : A resource management, synchronization, and locking tool. 

Description : State the methods of task synchronization. Describe semaphore with suitable example.

Last Answer : The methods of task synchronization are: Semaphore Message queue. Mutual exclusion.  Dead lock. Mailboxes. Message Queues. Semaphores: It is a system of sending message by using flags. Multiple concurrent threads of execution ...   signal(Sem);  }  in process P2  {  wait(Sem);  S2;  }

Description : An intuitive manager could best be described as one who: A)uses scientific problem solving B)eliminates uncertainty in decision making C)searches out facts and data systematically D)uses an orderly approach to gathering information E)uses personal knowledge and experience to make decisions

Last Answer : E)uses personal knowledge and experience to make decisions

Description : Who guides us while solving any problem?

Description : Explain data transfer mechanism in I2C protocol. Compare it with CAN and USB protocol based on bit rate and area of applications.

Last Answer : I2C (Inter-Integrated Circuit): I2C stands for Inter-Integrated Circuit. I2C is a serial protocol. It was developed by Philips Semiconductor. I2C bus have two communication lines. One is serial data ( ... Mbps this is used for lower speed devices. Using USB we can connect upto 127 devices.

Description : The following were the features of the Nation state that emerged in Europe in the 20th century. a. The concept and practices of a modern state with sovereign centralised power developed in Europe. ... identified their nations. Mainly female figures were used to portray the nation. d. None of these

Last Answer : b. Nation state was supposed to be a state where majority of its citizens shared common identify and history.

Description : Firms that truly adopt the marketing concept develop a distinct organisational culture based on a shared set of beliefs that make __________ the pivotal point of the firm's decisions ... beating competitors B)increasing market share C)customers' needs D)marketing implementation E)marketing control

Last Answer : C)customers' needs

Description : Explain what is the Statistical Problem Solving Process.

Description : How did underground railway help in solving housing problem ? -SST 10th

Last Answer : London Underground partially solved the housing crisis by carrying large masses of people to and fro the city.

Description : A transgenic food crop which may help in solving the problem of night blindness in developing countries is (a) Bt soybean (b) Golden rice (c) Flavr Savr tomatoes (d) Starlink maize.

Last Answer : b) Golden rice

Description : Pickup wrong definition 1) Off line - is a system peripheral equipment not controlled by CPU 2) Online - is system in which peripheral equipment is in direct contact with CPU 3) PL/I is the ... /Index 4) Program or routine is a set sequence of instructions given to computer for problem solving

Last Answer : 3) PL/I is the acronym Peripheral Listing /Index

Description : Language is best thought of as Options: A) A biological (instinctive) development B) A system of symbols for effective problem-solving C) A nomenclature for cataloguing experience D) A medium for self-enhancement

Last Answer : C) A nomenclature for cataloguing experience 

Description : How can we improve our problem-solving skills?

Last Answer : Improving problem-solving skills requires practice and learning new techniques. Solutions include learning to analyze problems systematically, seeking out new perspectives, and brainstorming potential solutions.

Description : Why is problem solving skill important for an entrepreneur?

Description : “The role of alcohol in traffic safety has caused the greatest threat to safety”. On the basis of your understanding, suggest any two ways of solving this problem.

Description : Divya loved solving ....... a) problem b) sums c) mysteries

Description : What sort of problem solving do you do every day?

Last Answer : This question could be answered many ways. For me it is dealing with Bipolar. Simply because some days I battle to function. More importantly though, it is the shit my illness causes. Like when I simply ... precious now. I've learned a lot from this illness. Oddly I wouldn't change a thing! :)

Description : Which version of problem-solving method should I choose to keep my self-esteem due to almost-discovered lies?

Last Answer : answer:Which version should you choose? Do what you think is right.

Description : Did you hear anything about the space station having something to do with solving the problem of future radiation meltdowns?

Last Answer : No, the space station could not divert radiation. No possible way it could do that.

Description : How good at problem-solving are you (scenarios inside)?

Last Answer : answer:1. Get off the bus and call for a ride. 2. Hunker down and bust out my emergency kit, light some flares and wait for someone to drive by. A lot of this depends on where you've broken down. The ... for it. No one ever got out of a bad situation by freaking out, you have to think of a solution.

Description : What are some math applications and problem solving practice questions websites are pretty good to use to get ready for the CPT(college placement testing)

Last Answer : I am not familiar with any websites, but Kaplan and Barron both publish excellent test prep books for most college placement tests. These books usually come with cd's with problems and your local public ... public library doesn't, an academic library (local college or high school) might have a copy.

Description : What are the five stages in the Ladder of Problem Solving from "Thinking through Problem Solving"?

Last Answer : answer:http://www.changethis.com/21.ThinkingThrough The five stages: detection, inclination, capability, inquiry, skilled-response, and directed response. I know that's six. Maybe you only use one or the other of the last two?

Description : What's your weirdest approach to problem solving?

Last Answer : Put in an earbud and figure it out as you go

Description : Irrigation is very necessary for solving the food problem. -SST 10th

Last Answer : Agricultural crops are varied. Ample supply of water is required during the period of growth.

Description : The probability of A, B, C solving a problem are 1/3, 2/7 and 3/8 respectively. -Maths 9th

Last Answer : Let E1, E2, E3 be the eventsthat the problem issolved by A, B, C respectively and let p1, p2, p3 be corresponding probabilities. Then,p1 = P(E1) = \(rac{1}{3}\), p2 = P(E2) = \(rac{2}{7}\), p3 = P(E3) = \(rac{3}{8}\) ... }{8}\) = \(rac{25}{168}\) + \(rac{5}{42}\) + \(rac{5}{28}\) = \(rac{25}{56}.\)

Description : A problem in mathematics is given to four students A, B, C and D. Their chances of solving the problem -Maths 9th

Last Answer : Given, P(A) = \(rac{1}{2}\) ⇒ P(\(\bar{A}\)) = P(A not solving the problem) = 1 - \(rac{1}{2}\) = \(rac{1}{2}\)P(B) = \(rac{1}{3}\) ⇒ P(\(\bar{B}\)) = 1 - \(rac{1}{3}\) = \(rac{2}{3}\)P(C) = \ ... 3}{4}\)x \(rac{4}{5}\) = \(rac{1}{5}\)∴ P(problem will be solved) = 1 - \(rac{1}{5}\) = \(rac{4}{5}\).

Description : Problem solving

Last Answer : People crossed the bridge in groups of 2 and 3, Twenty one people crossed, How many groups of 2 were there, How many of 3?