rtems_task acting strange

Salman unix at gofree.indigo.ie
Wed Mar 12 11:34:33 UTC 2003


Hi guys,

I'm observing strange behavior when executing the following osif_init
function.

It gets as far as printing "were gonna startthe task 0 !!!!" (status = 0
-> successful task creation) and waiting for return key.
when I press return key, it goes mental, the screen either starts
dumping infinite garbage, or I get a page of errors with heading related
to thread error or something (i can't fully read it, cos system reboots
straight afterwards)

any idea whats going wrong ?

thanks

Salman

----------------- the related functions ------------------
int osif_init(osif_init_args_t args)
{

   rtems_status_code status;
   rtems_id   Task_id;

	/* debugging info*/
        printk ("osif_c #2: were here\n");
        fflush(stdout);
        getchar();

  UnitCount++;
  if (UnitCount > 1) {
    return(0);
  }

  first_timeout = NULL;
  main_driver_lock=sem_open("main_driver_lock",O_CREAT,0,1);
  if (main_driver_lock==(sem_t *) -1)
    printk("osif_init");

  Dma_lock=sem_open("Dma_lock",O_CREAT,0,1);
  if (Dma_lock==(sem_t *) -1)
    printk("osif_init");

  FlagInt_lock=sem_open("FlagInt_lock",O_CREAT,0,1);
  if (FlagInt_lock==(sem_t *) -1)
    printk("osif_init");

  AttIndex_lock=sem_open("AttIndex_lock",O_CREAT,0,1);
  if (AttIndex_lock==(sem_t *) -1)
    printk("osif_init");

  time_q_lock=sem_open("time_q_lock",O_CREAT,0,1);
  if (time_q_lock==(sem_t *) -1)
    printk("osif_init");

  to_lock=sem_open("tot_lock",O_CREAT,0,0);
  if (to_lock==(sem_t *) -1)
    printk("osif_init");

/* two tasks start here in vxworks
 * but are sequentially implemented in linux
 * fix required
 * done
 * one is related to interrupts which we're doing sequentialy in
sci_interrupthandler, like linux
 * the other is a task related to timeouts etc, which we implemented as
rtems_task
 * taskSpawn("TOT_TASK",2,VX_FP_TASK,40000,(FUNCPTR)
to_task,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
 */

  status = rtems_task_create(
                  rtems_build_name( 'T', 'S', '0', '1'),
                  2, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
                  RTEMS_DEFAULT_ATTRIBUTES, &Task_id);

	/* debugging info*/
	printf("were gonna startthe task %i !!!!",(int)status);
	getchar();
  status = rtems_task_start( Task_id, to_task, 1);
  return 0;
}

rtems_task to_task(rtems_task_argument unused)
{
    int gto_data;
    int retval;
    struct mq_attr attr;
   /* commented out for debugging
    extern void general_timeout_handler( int data);*/

    attr.mq_flags   = 0;
    attr.mq_maxmsg  = 128;
    attr.mq_msgsize = sizeof(int);

	/* debugging info*/
    printk("were gonna do the mq_open thing");
    getchar();

    mq=mq_open("TOTDATA",O_RDWR|O_CREAT,NULL,&attr);

	/* debugging info*/
    printk("just did the mq_open thing");
    getchar();
    if (mq== (mqd_t ) -1)
    {
	/* debugging info*/
        printk("mq_open failed\n");
        getchar();
        rtems_task_suspend(RTEMS_SELF);
    }
	/* debugging info*/
        printk("mq_open passed\n");
        getchar();
/*  commented out for debugging
    for(;;)
    {
        retval=mq_receive(mq,&gto_data,sizeof(int),0);
        if (retval== -1)
        {
                printk("mq_open failed\n"); 
                rtems_task_suspend(RTEMS_SELF);
        }
        general_timeout_handler(gto_data);
    }
*/
}





More information about the users mailing list