Subject:
|
Re: The BrickOS Task Manager
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Sun, 4 Jan 2004 09:18:00 GMT
|
Viewed:
|
3967 times
|
| |
| |
Michael Purvis wrote:
> Hi everyone,
>
> I was wondering if there's any documentation or example programs detailing how
> to use the task manager in BrickOS. The only example I have is the line-follow
> program that somehow uses tasks to 'wake up' when it detects a colour change.
>
> Specifically, I'm looking to run a task that controls the physical operation of
> my bot and then another that does computations in the background. I'd like the
> computations to carry on while the bot is performing its various operations.
> Thanks for any help.
>
> Michael
>
>
>
To make a thread with BrickOS (I use the 0.2.4, but I think that the
method is the same !)
You need to use the execi function :
pid_t my_thread;
... (function other declaration
int funct(int argc, char *argv[])
{
// Function that the robot ahve to make
// [FUNCT]
}
int main()
{
// [MAIN]
my_thread=execi(&funct, 0, 0, PRIO_NORMAL, DEFAULT_STACK_SIZE); //
run the function in backround
while(!end);
kill(my_thread); //stop function
}
I've notice that if ou call a function in the [FUNCT] domain then the
function is not include in the thread and stop all other task ... That's
really important in certain program
Some note about execi function :
1st argument : the adress of the funct you want to thread
2nd & 3rd are argument you passed in the function (value of int argc,
char *argv[])
4th : the priority of the thread ! 2 function can't have the same priority.
5th : the stack size, commonly we put the value DEFAULT_STACK_SIZE (512)
I think that's all you need to know ;-)
nanobapt
|
|
Message has 1 Reply: | | Re: The BrickOS Task Manager
|
| (...) Hmm... it doesn't seem to recognize pid_t as a valid type. I have a document of the functions in brickOS that indicates execi returning an int. Which is it? (...) Still confused... I'll post the poignant code: pid_t rowthread; pid_t colthread; (...) (21 years ago, 5-Jan-04, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | The BrickOS Task Manager
|
| Hi everyone, I was wondering if there's any documentation or example programs detailing how to use the task manager in BrickOS. The only example I have is the line-follow program that somehow uses tasks to 'wake up' when it detects a colour change. (...) (21 years ago, 4-Jan-04, to lugnet.robotics.rcx.legos)
|
15 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|