Subject:
|
Re: The BrickOS Task Manager
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Tue, 13 Jan 2004 17:02:01 GMT
|
Viewed:
|
4268 times
|
| |
| |
In lugnet.robotics.rcx.legos, Michael Purvis wrote:
> On the execi lines, it complains about not being able to convert int (*) to int
> (*)(something... ) I think it's referring to the fact that in the actual
> definition of execi (in unistd.h, I think), that's the parameter type. I don't
> understand how it could work as c but not as cpp.
C++ is more particular with types than regular ol' C. However, I think
BrickOS's definition of NULL in mem.h is incorrect (as this was causing one of
the problems in the execi call). IMO, it should be defined like so:
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
Also, I tossed in some msleep() calls to free up cpu so low priority tasks (if
any) can run.
Cheers,
Mark
#include <unistd.h>
#include <dbutton.h>
#include <dmotor.h>
MotorDirection _dir = off;
int RunMotor(int argc, char* argv[])
{
while (!shutdown_requested())
{
motor_a_dir(_dir);
msleep(1);
}
return 0;
}
int CheckButton(int argc, char* argv[])
{
while (!shutdown_requested())
{
if (PRESSED(dbutton(),BUTTON_PROGRAM))
_dir = fwd;
else
_dir = off;
msleep(1);
}
return 0;
}
int main()
{
execi(CheckButton, 0, 0, PRIO_NORMAL, DEFAULT_STACK_SIZE);
execi(RunMotor, 0, 0, PRIO_NORMAL, DEFAULT_STACK_SIZE);
while(!shutdown_requested())
msleep(100);
return 0;
}
|
|
Message is in Reply To:
| | Re: The BrickOS Task Manager
|
| (...) When saved as multi.c, but not when saved as multi.cpp (...) Start multiple tasks within a program that uses objects. I could rewrite a number of parts to use structs instead, but I just wanted to check that there wasn't some easy solution. (...) (21 years ago, 13-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
|
|
|
|