task not relinquishing scheduler busy waiting..
Chan Kim
ckim at etri.re.kr
Mon Aug 31 08:28:52 UTC 2015
Hi, rtems users,
Please someone help me fix my problem. I think this should be an easy question for those familiar with rtems
I'm implementing a SD card driver and now can read, write files on SD card but it's very slow.
I trigger the request and wait until the processing is done. For completion, thread 3 needs to run getting events from ISR.
Till now, I used rtems_task_wake_after() in thread 1 until it's done which
is a partial reason why it's so slow. (unit delay is 1/100 seconds) -- method 1 below.
If I can use a finer grain delay(wait) I could use it. (if there's one please tell me..)
I tried using busy waiting in thread 1(= main thread) -- method 2 below.
But this busy waiting makes that thread not relinquish the scheduler and runs indefinately.
(thread 3 cannot run, so the processing is not completed. it's deadlock.)
------------ code running in thread 1 --------------
static volatile delaycnt = 0;
static mdelay(int cnt)
{
int i;
for(i=0;i<cnt;i++) {
delaycnt++;
}
printk("mdelay exp\n");
}
static void mmc_wait_for_req_done(ald_sd *host, //mmc_host *host,
struct mmc_request *mrq)
{
struct mmc_command *cmd;
int timeout = 0x40000000;
while (timeout--) {
if (mrq->completion.done == 1) return;
//else rtems_task_wake_after(1); <------ method 1
else mdelay(1000); <-------- method 2
}
--------------------------
I changed my CONFIGURE_INIT_TASK_PRIORITY to 100. and I created thread 3 using priority 99.
To create task 3 , I used code below,
--------------
sc = rtems_task_create (rtems_build_name(nm[0], nm[1], nm[2], nm[3]),
99, //priority
stacksize,
RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
&tid);
...
sc = rtems_task_start (tid, (rtems_task_entry)entry, (rtems_task_argument)t);
---------------
But I realized rtems_task_start function only makes the thread in 'READY' state, but not actaully executes it.
How do I make task 3 get a chance to run (take scheduler) when task 1 is busy waiting? should I set a scheduler algorithm?
Thanks in advance.
Chan
More information about the users
mailing list