Study Doc Usama
Study Doc Usama
2) a=a+b
b=a-b
a=a-b
3)
int *ptr1,*ptr2
int a;
a=*ptr1
*ptr1=*ptr2
*ptr2=a
Assume that 0x7600 is an address. How will you store 50 in that address?
*((int * ) 0x7600) = 50;
What is Node –
struct node {
int data;
struct node* next;
};
You can call a function from an isr if it is only the isr that is calling the function. Then it can be considered as part of
the isr.If some other part of the program is also calling the function, then it must be a re-entrant function. The isr
might interrupt when the program is inside the function.A re-entrant function is a function that does not use global or
static variables and does not call other non re-entrant functions.Some compilers will flag an error if an isr calls a
Re-entrancy
Some of the answers the thread aren't totally clear, so I hope to clarify some of that here. Re-entrancy is only an
issue if a function is shared across multiple execution contexts. I could put some formal definition, but I think it
1. int x;
2.
3. void foo(int z)
4. {
5. x = z;
6. }
7.
8. void ISR()
9. {
10. x++;
Now, depending upon the architecture, this code could create strange values for x depending
upon when foo() and ISR() run. For example, if x is a 32-bit integer and we are on an 8-bit
platform, it usually requires several instructions to update x. If the interrupt occurred in the
middle of that update to x, the contents of x could be corrupted.
CISC RISC
Emphasis on hardware Emphasis on software
Includes multi-clock Single-clock, http://www-cs-faculty.stanford.edu/
complex instructions reduced instruction only ~eroberts/courses/soco/projects/
Memory-to-memory: Register to register: 2000-01/risc/risccisc/
"LOAD" and "STORE" "LOAD" and "STORE"
incorporated in instructions are independent instructions
Small code sizes, Low cycles per second,
high cycles per second large code sizes
Transistors used for storing Spends more transistors
complex instructions on memory registers
17.What is RTOS?
18.What is the difference between hard real-time and soft real-time OS?
A real-time operating system (RTOS) is an operating system (OS) intended to serve real-time
application requests.
A key characteristic of an RTOS is the level of its consistency concerning the amount of time it
takes to accept and complete an application's task; the variability is jitter.[1] A hard real-time
operating system has less jitter than a soft real-time operating system. The chief design goal is
not high throughput, but rather a guarantee of a soft or hard performance category. An RTOS
that can usually or generally meet a deadline is a soft real-time OS, but if it can meet a deadline
deterministically it is a hard real-time OS.
An RTOS has an advanced algorithm for scheduling.Key factors in a real-time OS are minimal
interrupt latency and minimal thread switching latency; a real-time OS is valued more for how
quickly or how predictably it can respond than for the amount of work it can perform in a given
period of time
As the name suggests, there is a deadline associated with tasks and an RTOS adheres to this
deadline as missing a deadline can cause affects ranging from undesired to catastrophic. The
example of airbag which causes catastrophic affect of an RTOS missing a deadline.
A scheduler is the heart of every RTOS. It provides the algorithms to select the task for execution. Three
common scheduling algorithms are
Priority inversion is a situation where in lower priority tasks will run blocking higher priority tasks waiting
for resource (mutex). For ex: consider 3 tasks. A, B and C, A being highest priority task and C is lowest.
Look at sequence of context swaps A and C have shared resource
A goes for I/O .
C was ready to run. So C starts running. locks resource
B is ready to run. but B is not using share resource of A and C. Swaps out C and start execution
now A is ready to run but resource is locked by C
. after B finished C will continue..and B wise versa.. A still wait to run.
To avoid this situation exchange the priority levels of A and C. After this C will become highest priority
and gets the CPU time by suspending task B. Task C will be serviced and releases resource shared with
task A. As soon as task C is released the shared resource change the prority levels of A and C again. Now
A will become highest priority than C and CPU starts running Task A.
What is semaphore?
Semaphore is a location in memory whose value can be tested and set by more than one process.
Semaphor is a positive value set by the kernel against the number of shared resources available at any
given point of time. if one process occupies the shared resource, the value of semaphor is decremented
(P operation) by one and so on until it becomes zero when all resources are occupied. When a process
releases the resource, semaphor value is incremented (V operation).
Suppose a library has 10 identical study rooms, intended to be used by one student at a time. To prevent
disputes, students must request a room from the front counter if they wish to make use of a study
room. When a student has finished using a room, the student must return to the counter and indicate
that one room has become free. If no rooms are free, students wait at the counter until someone
relinquishes a room.The librarian at the front desk does not keep track of which room is occupied, only
the number of free rooms available. When a student requests a room, the librarian decreases this
number. When a student releases a room, the librarian increases this number. Once access to a room is
granted, the room can be used for as long as desired, and so it is not possible to book rooms ahead of
time.In this scenario the front desk represents a semaphore, the rooms are the resources, and the
students represent processes. The value of the semaphore in this scenario is initially 10. When a student
requests a room he or she is granted access and the value of the semaphore is changed to 9. After the
next student comes, it drops to 8, then 7 and so on. If someone requests a room and the resulting value
of the semaphore is negative,[2] they are forced to wait. When multiple people are waiting, they will
either wait in a queue, or use Round-robin scheduling and race back to the counter when someone
releases a room (depending on the nature of the semaphore).
What is difference between binary semaphore and mutex?
When number of resources a Semaphore protects is greater than 1, it is called a Counting Semaphore.
When it controls one resource, it is called a Boolean Semaphore. A boolean semaphore is equivalent to a
mutex.Mutex:
Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the
person gives (frees) the key to the next person in the queue.
A mutex object only allows one thread into a controlled section, forcing other threads which attempt to
gain access to that section to wait until the first thread has exited from that section.
Is the number of free identical toilet keys. Example, say we have four toilets with identical locks and
keys. The semaphore count - the count of keys - is set to 4 at beginning (all four toilets are free), then
the count value is decremented as people are coming in. If all toilets are full, ie. there are no free keys
left, the semaphore count is 0. Now, when eq. one person leaves the toilet, semaphore is increased to 1
(one free key), and given to the next person in the queue.
Officially: "A semaphore restricts the number of simultaneous users of a shared resource up to a
maximum number. Threads can request access to the resource (decrementing the semaphore), and can
signal that they have finished using the resource (incrementing the semaphore)." Ref: Symbian
Developer Library
If the watchdog timer expires, it is because the software hasn't retriggered it often enough. The
software might be stuck in a loop somewhere, or it might have crashed altogether. In any event, it is a
problem, and you have to recover.
http://gelliphanindraviswanadhaprasad.org/interview-questions/embedded-interview-questions/
To study
1.RISC vs CISC
2.typedef
3.Diff between union n structure
4.hardware latency
5. What is rentrant?