You are on page 1of 4

Write a code to connect Hardware interrupt to ISR...?

void serial_ISR() interrupt 4 using 0


{
}
& in AVR studio
SIGNAL(Inteerupt_no)
{
}
hardware intterupt normally redirects the uC to predefined
addresses. In case of high end processors the interrupt
table will decide the interrupt vector address and whenever
intterrupt pin goes low, the table is searched for type and
source of interrupt.
Re: what is task spawn in vxworks ?plz anyone explain me
The VxWorks multitasking kernel, wind, uses interrupt-driven, priority-based tas
k scheduling. It features fast context switch times and low interrupt latency. U
nder VxWorks, any subroutine can be spawned as a separate task, with its own con
text and stack. Other basic task control facilities allow tasks to be suspended,
resumed, deleted, delayed, and moved in priority.
ok. here we go.
taskSpawn is used to create a thread in VXworks.
Once the thread is created than only we can make all the suspended,delete,resume
operations.
Syntax
taskSpawn(char *name,int priority,int option,int stacksize,FUNCPTR entrypoint,in
t avg1,avg2....avg10)
1. name: task name examp: task1
2. priority: 0-255 //0---high, 255---low
3.options: 0 most of the times
4.FUNCPTR: It jumps to function we are calling examp; (FUNCPTR)fun1
5.avg1--avg10: almost 0 every time
Assume there is a global variable & a static global
variable.Both gets memory allocated from the data segment.
Then how does the visiblity of static global varible gets
limited to the file alone (in which it gets declared) ???
Static variables are local in scope to their module in which
they are defined, but life is throughout the program. Say
for a static variable inside a function cannot be called
from outside the function (because it's not in scope) but is
alive and exists in memory. The next time this function is
entered (within the same program) the same chunk of memory
would be accessed now retaining the variables old value and
no new memory is allocated this time for this variable like
other variables in the function (automatic variables). So
basically the variable persists throughout the program.
Similarly if a static variable is defined in a global space
(say at beginning of file) then this variable will be
accessible only in this file (file scope).
A static global variable is having internal linkage. Once
the object file is created, this variable is not given to
the linker. Hence it is limited to the file alone.
Re: What is priority inversion?
Answer
# 8
Priority inversion is a situation where in lower priority
tasks will run blocking higher priority tasks waiting for
resource (mutex).
priority: A(High) B(Medium) C(Low)
C was ready to run. So C starts running. locks mutex
A is ready to run. Bcz of A is higher priority than C, A
gets the CPU (otherwords C relinguishes CPU).
While executing "A" task, it's need of resource(mutex) but
it locked by lower priority task "C". so task "A" going to
be waiting state(priority inversion)
B is ready to run. Bcz B is Higher priority than C, B get
the CPU frm C.
For task "B", its no need of any resource(mutex). so it
wont be waiting for any task to get resource. it will be
finished first.
Then, Task "C" gets CPU from task "B" and finished its
task, and reliese the resource(mutex).
Task C (waiting task for resource)then gets mutex finish
execution..
Here:
B(M) task finished exe first
C(L) task finished exe second
A(H) task finished exe last even its have higher priority
than both B and C
The solution to priority inversion is Priority inheritance
Priority inheritence is the solution.This mechanism raises
the priority of the smaller task equal to the higher
priority task and after completion of the task,unlocks the
semaphore and returns back to the original lower
priority.This process is done by the scheduler.
Take three tasks A,B and C.
A - High.
B - Medium.
C - Low.
C is scheduled and running and locks a resource which is
shared with A. Now B is scheduled and taked the CPU time so
it starts running keeping C in wait state.
Now A is scheduled which is the higher priority task than B
and C and gets the CPU time and it starts running. But it
needs the shared resource which is locked by task C. So A
waits for that resource.
Now CPU starts servicing task B as it has higher priority
than C. A is suppose to wait till task B is finished even
though it has highest priority than B. 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.
This is called Proirity inversion.
Re: Which RTOS supports Non-Preemptive scheduling ? Why other scheduling methods
are supported by such Oses?
The standard UNIX kernel is a nonpreemptive kernel; it does
not allow a user process to preempt a process executing in
kernel mode. Once a running process issues a system call and
enters kernel mode, preemptive context switches are disabled
until the system call is completed. Although there are
context switches, a system call may take an arbitrarily long
time to execute without voluntarily giving up the processor.
During that time, the process that made the system call may
delay the execution of a higher-priority, runnable, realtime
process.
The maximum process preemption latency for a nonpreemptive
kernel is the maximum amount of time it can take for the
running, kernel-mode process to switch out of kernel mode
back into user mode and then be preempted by a
higher-priority process. Under these conditions it is not
unusual for worst-case preemption to take seconds, which is
clearly unacceptable for many realtime applications.
What is another for creating a task without using taskspawn?
Instead of taskspawn
taskInit and taskActivate can be used to create task.
taskInit->It will initialize the task at specified address
taskActivate->It will activate the initialised task
Re: I have a situation where the programme counter(PC) shows that vxworks msgQre
ceive function has been called by task A and Q is full, still I am not picking u
p the messages. There is no other task registered to receive messages from this
Q. The sending task B, which is ISR in this case, is getting timedout everytime
it tries posting new message in it. A's state is PEND which means I am waiting f
or some resource to get free but PC shows I have called vxworks msgQReceive and
currently at qJobget+0x018 location. There seems to be two causes now(identified
by me): either vxworks qjobget task is not able to do semTake or no messages in
Q. But Q is full and semTake failure seems unlikely(though I dont have a mechan
ism to check so). Besides explaining root cause for above, can anyone suggest ho
w to get my task in READY state again? I also tried flushing the Q; on doing thi
s, more messages get posted in Q but A still doesnt pick up any :(
Thanks Gaurav for ur answer. But if B is using WAIT_FOREVER,
it should never timed out, right? Also, all application
tasks are runnig n at same priority in preemptive manner.
Anyhow, in this case, I found that qJobGet() of vxworks is a
lower level generic function which is used by many other
routines including msgSend. If this is the case, I am trying
out following:
1. I am trying to get a stack dump of this task. Though it
would involve lot of labour but I am hoping to take a dump
of valid addresses that I found in its stack. This should
help in obtaining actual caller of qJobGet(). This way, we
might find the resource our task A is actually wai6ting for
to acquire(it should be either of some vxworks semaphore or
msgQ itself).
2. Second, I found that task structure of vxworks contains a
variable that stores the address of the object task is
currently PENDed on. If that address can be dumped, again we
can hope to progress from here.
Unfortunately am using an older version of vxworks and can
not afford to upgrade to later versions. So, many of the
utilities found on web have to be actually written using
available vxworks's online tools.

You might also like