Problems with pistachio

Ashford Nichols <[email protected]> Wed, 1 Jun 2011 05:53:32 -0700
Newsgroups gmane.comp.micro-kernel.l4.l4ka.general
Message-ID <[email protected]>
--00504502b67b0bc58404a4a602a6
Content-Type: text/plain; charset=ISO-8859-1

Since i have been using pistachio i have encountered various problems that i
can't seem to fix. The problems are as followed:

1) I don't seem to be able to acknowledge interrupts. I get the very first
interrupt IPC that occurs for a specified irq, but after that i don't
receive any more interrupt IPC from that interrupt thread. My interrupt
pager simply prints a message to show that it received the interrupt IPC,
attempts to acknowledge the interrupt, then start over the process. The code
looks like this:

irq1 = L4_GlobalId(1, 1); //keyboard interrupt

void int_pager(void)
{
L4_MsgTag_t tag;
while(1)
{
tag = L4_Wait(irq1);
if(L4_Label(tag) == 65520) printf("interrupt received\n"); //ensures it is
an interrupt ipc
L4_Set_MsgTag(L4_niltag); //attempts to acknowledge interrupt
tag = L4_Send(irq1);
if(L4_IpcFailed(tag)) printf("acknowledge failed\n"); //bit of error
checking
}
}

when the code runs "interrupt received" is printed only ONCE, suggesting
that the interrupt was not unmasked. Where am I going wrong?

2) I have created a test application that creates two thread that
communicates with each other. The two thread are successfully created.
Initially thread A waits for an IPC from thread B, but before thread B has a
chance to send the IPC, thread A is invoked thus causing the entire
application to hang, since thread A is waiting for B and B can't execute
because thread A is waiting. The code looks like this:

L4_ThreadId_t TA, TB;

void threadA(void)
{
L4_Msg_t msg;
L4_MsgTag_t tag;
L4_Word_t misc;
while(1)
{
L4_Wait(TB);
L4_StoreMR(1, &misc);
if(misc == 45)
{
printf("%d received\n", (int)misc);
L4_Clear(&msg);
L4_Append(&msg, 54);
L4_Load(&msg);
tag = L4_Send(TB);
if(L4_IpcFailed(tag)) printf("A) ipc failed\n"); //bit of error checking
}
}
}

void threadB(void)
{
L4_Msg_t msg;
L4_MsgTag_t tag;
L4_Word_t misc;
while(1)
{
L4_Clear(&msg);
L4_Append(&msg, 45);
L4_Load(&msg);
tag = L4_Send(TA);
if(L4_IpcSucceeded(tag))
{
L4_Wait(TA);
L4_StoreMR(1, &misc);
if(misc == 54) printf("B) %d received\n", (int)misc);
}
else printf("B) ipc failed\n");
}
}

int main()
{
TB = new_thread(threadB);
TA = new_thread(threadA);

L4_Sleep(L4_Never);
return 0;
}

My guess is that the timeslice expires before the thread starts sending the
IPC. In one case I attempted to setting the timeslice of both threads,
before activating them, but nothing changed. The code to set the timeslice
looks like this:

L4_ThreadControl(tid, me, me, L4_nilthread, (void*)tid_utcb); //did not
activate thread yet
L4_Word_t ts = L4_TimePeriod(5000000); //5 seconds should be enough
L4_Set_Timeslice(tid, ts, L4_Never);
L4_ThreadControl(tid, me, me, me, -1); //activate thread

3) Also a general question. When creating threads, to obtain a new utcb,
this piece of code is needed:

root_utcb &= ~(L4_UtcbAreaSize(kip) - 1);

why is this needed, if the utcb location of a thread is already equal to the
local id of the thread?

Ashford

--00504502b67b0bc58404a4a602a6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<span class=3D"Apple-style-span" style=3D"border-collapse: collapse; font-f=
amily: arial, sans-serif; font-size: 13px; ">Since i have been using pistac=
hio i have encountered various problems that i can&#39;t seem to fix. The p=
roblems are as followed:<div>
<br></div><div>1) I don&#39;t seem to be able to acknowledge interrupts. I =
get the very first interrupt IPC that occurs for a specified irq, but after=
 that i don&#39;t receive any more interrupt IPC from that interrupt thread=
. My interrupt pager simply prints a message to show that it received the i=
nterrupt IPC, attempts to acknowledge the interrupt, then start over the pr=
ocess. The code looks like this:</div>
<div><br></div><div>irq1 =3D L4_GlobalId(1, 1); //keyboard interrupt</div><=
div><br></div><div>void int_pager(void)</div><div>{</div><div>L4_MsgTag_t t=
ag;</div><div>while(1)</div><div>{</div><div>tag =3D L4_Wait(irq1);</div><d=
iv>
if(L4_Label(tag) =3D=3D 65520) printf(&quot;interrupt received\n&quot;); //=
ensures it is an interrupt ipc</div><div>L4_Set_MsgTag(L4_niltag); //attemp=
ts to acknowledge interrupt</div><div>tag =3D L4_Send(irq1);</div><div>if(L=
4_IpcFailed(tag)) printf(&quot;acknowledge failed\n&quot;); //bit of error =
checking</div>
<div>}</div><div>}</div><div><br></div><div>when the code runs &quot;interr=
upt received&quot; is printed only ONCE, suggesting that the interrupt was =
not unmasked. Where am I going wrong?</div><div><br></div><div>2) I have cr=
eated a test application that creates two thread that communicates with eac=
h other. The two thread are successfully created. Initially thread A waits =
for an IPC from thread B, but before thread B has a chance to send the IPC,=
 thread A is invoked thus causing the entire application to hang, since thr=
ead A is waiting for B and B can&#39;t execute because thread A is waiting.=
 The code looks like this:</div>
<div><br></div><div>L4_ThreadId_t TA, TB;</div><div><br></div><div>void thr=
eadA(void)</div><div>{</div><div>L4_Msg_t msg;</div><div>L4_MsgTag_t tag;</=
div><div>L4_Word_t misc;</div><div>while(1)</div><div>{</div><div>L4_Wait(T=
B);</div>
<div>L4_StoreMR(1, &amp;misc);</div><div>if(misc =3D=3D 45)</div><div>{</di=
v><div>printf(&quot;%d received\n&quot;, (int)misc);</div><div>L4_Clear(&am=
p;msg);</div><div>L4_Append(&amp;msg, 54);</div><div>L4_Load(&amp;msg);</di=
v>
<div>tag =3D L4_Send(TB);</div><div>if(L4_IpcFailed(tag)) printf(&quot;A) i=
pc failed\n&quot;); //bit of error checking</div><div>}</div><div>}</div><d=
iv>}</div><div><br></div><div>void threadB(void)</div><div>{</div><div>L4_M=
sg_t msg;</div>
<div>L4_MsgTag_t tag;</div><div>L4_Word_t misc;</div><div>while(1)</div><di=
v>{</div><div>L4_Clear(&amp;msg);</div><div>L4_Append(&amp;msg, 45);</div><=
div>L4_Load(&amp;msg);</div><div>tag =3D L4_Send(TA);</div><div>if(L4_IpcSu=
cceeded(tag))</div>
<div>{</div><div>L4_Wait(TA);</div><div>L4_StoreMR(1, &amp;misc);</div><div=
>if(misc =3D=3D 54) printf(&quot;B) %d received\n&quot;, (int)misc);</div><=
div>}</div><div>else printf(&quot;B) ipc failed\n&quot;);</div><div>}</div>
<div>}</div><div><br></div><div>int main()</div><div>{</div><div>TB =3D new=
_thread(threadB);</div><div>TA =3D new_thread(threadA);</div><div><br></div=
><div>L4_Sleep(L4_Never);</div><div>return 0;</div><div>}</div><div><br></d=
iv>
<div>My guess is that the timeslice=A0expires before the thread starts send=
ing the IPC. In one case I attempted to setting the timeslice of both threa=
ds, before activating them, but nothing changed. The code to set the timesl=
ice looks like this:</div>
<div><br></div><div>L4_ThreadControl(tid, me, me, L4_nilthread, (void*)tid_=
utcb); //did not activate thread yet</div><div>L4_Word_t ts =3D L4_TimePeri=
od(5000000); //5 seconds should be enough</div><div>L4_Set_Timeslice(tid, t=
s, L4_Never);</div>
<div>L4_ThreadControl(tid, me, me, me, -1); //activate thread</div><div><br=
></div><div>3) Also a general question. When creating threads, to obtain a =
new utcb, this piece of code is needed:</div><div><br></div><div>root_utcb =
&amp;=3D ~(L4_UtcbAreaSize(kip) - 1);</div>
<div><br></div><div>why is this needed, if the utcb location of a thread is=
 already equal to the local id of the thread?</div><div><br></div><font col=
or=3D"#888888"><div>Ashford</div></font></span>

--00504502b67b0bc58404a4a602a6--