By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,514 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,514 IT Pros & Developers. It's quick & easy.

more task related questions..

P: n/a
Come to think of it I have another question:

With respect to priority task1 is the highest, task2 is the lowest. The

SEM_ID task1_sema = semBCreate(SEM_Q_FIFO, SEM_EMPTY);
SEM_ID task2_sema = semBCreate(SEM_Q_FIFO, SEM_EMPTY);

void compute_like_crazy()
void give_t1_sema() { semGive(task1_sema); }

void give_t2_sema() { semGive(task2_sema); }

void give_both_sema() {

void task1()
while (1)
if (semTake(task1_sema, WAIT_FOREVER) != OK)
std::cout << " task one started " << endl;

for (int idx(0); idx < 10000; ++idx)
taskDelay(sysClkRateGet() * 1);
std::cout << " hi there from task one " << endl;
void task2()
while (1)
if (semTake(task2_sema, WAIT_FOREVER) != OK)
std::cout << " task two started " << endl;

std::cout << " hi there from task two " << endl;

I was surpised to learn that if I typed give_both_sema at the console
The result prints:
task one started
task two started
hi there from task two
hi there from task one

The reason for my suprise surrounds the fact that I was of the
impression that the _highest_ priority task - in this case - task1
(which executed first) is in control of the CPU. That said, task2 will
literally have to 'wait' until task1 is complete before executing. The
results show otherwise. 'hi there from task two' prints before 'high
there from task one'. Does this mean task2 suspends 'task1' or .. what
am I missing. Not sure how two task could execute at the same time?

Being new to vxWorks I suspect it's time to pull out the manual again
since I'm not sure my understanding of high and lower prority tasks are
in synch with the output.

Oct 25 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Sorry guys. I realize I goof. Picked the wrong group.
My apologies.

Oct 25 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.