this code give:
#include <l4/kip.h> #include <l4/thread.h> #include <l4/schedule.h> #include <l4/ipc.h> #include <l4io.h> #include <l4/sigma0.h>
L4_ThreadId_t INT_THREAD;
void IRH1(void) { while(1) { L4_Msg_t msg; printf("the interrupt is raise\n"); L4_Clear(&msg); L4_Append(&msg,(L4_Word_t)0); L4_Load(&msg); L4_Send(INT_THREAD, L4_TimePeriod(2000000)); printf("result: [%d]\n", (int)L4_ErrorCode()); } }
int main() { L4_Word_t sp, ip, utcb_b, utcb_n; L4_ThreadId_t me, h1, mylocal; void* kip; char stack[1024]; L4_Msg_t msg; kip = L4_KernelInterface(); me = L4_MyGlobalId(); mylocal = L4_MyLocalId(); h1 = L4_GlobalId(L4_ThreadNo(me)+1, 2); utcb_b = *(L4_Word_t*)&mylocal; utcb_b &= ~(L4_UtcbAreaSize(kip) -1); utcb_n = utcb_b + (L4_UtcbSize(kip) * (L4_ThreadNo(h1) - L4_ThreadIdUserBase(kip))); sp = (L4_Word_t)&stack[1025]; ip = (L4_Word_t)IRH1; INT_THREAD = L4_GlobalId(1,1); L4_ThreadControl(h1, me, me, me, (void*)utcb_n); L4_Clear(&msg); L4_Append(&msg, ip); L4_Append(&msg, sp); L4_Load(&msg); L4_Send(h1, L4_TimePeriod(3000000)); printf("error code [%d]\n", (int)L4_ErrorCode()); L4_AssociateInterrupt(INT_THREAD,h1); while(1) { L4_Wait(L4_TimePeriod(3000000), &INT_THREAD); } return 0; }
give me a endless loop where a error code of 1 arise first then it loop endless with a error code of 2, this happen when keyboard is not press. Just to be clear by error code i mean the 'e' field of register. And if use 'sleep' instead wait it do not work when keyboard is press. as well how do i know if the interrupt is calling thread? I try if statement to compare the label to -1 but it it is not a legal compare because label is unsigned. how do i know?