|
From: Juras B. <yb...@tu...> - 2003-03-03 14:16:40
|
Hello oslib-devel,
just a sample code that doesn't work. why?
And what does TIME_NEW mean? there's no even a track of it in the
documentation. ll_gettime prints "LL time panic". And event_post,
called from the event handler generates exception 13. :((((
What I want is a simple task-switching cycle.
#include <ll/i386/stdlib.h>
#include <ll/i386/cons.h>
#include <ll/i386/error.h>
#include <ll/i386/mem.h>
#include <ll/i386/mb-info.h>
#include <ll/i386/pic.h>
#include <ll/i386/pit.h>
#include <ll/i386/hw-instr.h>
#include <ll/i386/hw-func.h>
#include <ll/sys/ll/ll-func.h>
#include <ll/sys/ll/event.h>
#include <sd32/typfix.h>
#include <sd32/sdinit.h>
// temp vars
char stk1[4*100];
char stk2[4*100];
CONTEXT thm,th1,th2;
CONTEXT ctx[3];
char active=0;
char *vmem=0xB8000;
struct ll_initparms ei;
struct timespec ts,tn;
void pth1(void*p)
{
while(1)
{
vmem[0]='1';
//ll_context_load(thm);
}
}
void pth2(void*p)
{
while(1)
{
vmem[0]='2';
//ll_context_load(thm);
}
}
void klr()
{
}
void ev_hnd(void*p);
void ev_hnd(void*p)
{
CONTEXT tc,cur;
cur=ll_context_from();
active++;
if (active>2) active=0;
tc=ctx[active];
// ll_gettime(TIME_NEW,&ts);
ADDNANO2TIMESPEC(100000000,&ts);
event_post(ts,ev_hnd,NULL);
vmem[1]=~vmem[1];
ll_context_to(tc);
}
void sd32_init(void) // called after ll_init
{
thm=ll_context_from();
th1=ll_context_create(pth1,stk1,NULL,klr,0);
th2=ll_context_create(pth2,stk2,NULL,klr,0);
ctx[0]=thm;
ctx[1]=th1;
ctx[2]=th2;
ei.mode=LL_PERIODIC;
ei.tick=1000; //ms
event_init(&ei); // if I try LL_ONESHOT, then there's an error message!!!
NULL_TIMESPEC(&ts);
ADDNANO2TIMESPEC(100000000,&ts);
// ll_gettime(TIME_EXACT,0); - doesn't work also!!!
// cli();
// printf_xy(0,1,"timenew: %d, timexact: %d\n",ll_gettime(TIME_NEW,&ts),ll_gettime(TIME_EXACT,&ts));
// sti();
// ADDNANO2TIMESPEC(100000000,&ts);
event_post(ts,ev_hnd,NULL);// calls event handler but after it
// halts :(
while(1)
{
vmem[0]='m';
//ll_context_load(th1);
//ll_context_load(th2);
}
}
--
Best regards,
Juras mailto:yb...@tu...
|