All of lore.kernel.org
 help / color / mirror / Atom feed
From: mani bhatti <imranbashirbhatti@domain.hid>
To: xenomai-help <xenomai@xenomai.org>
Subject: [Xenomai-help] porting to kernel 2.2
Date: Thu, 30 Nov 2006 08:45:32 -0800 (PST)	[thread overview]
Message-ID: <20061130164532.70291.qmail@domain.hid> (raw)
In-Reply-To: <451A9C64.7040802@domain.hid>


[-- Attachment #1.1: Type: text/plain, Size: 708 bytes --]



Hi all 
Previously i was working with 2.1 version of xenomai kernel but now i have kernel  2.2 and my previous code flags me error about  rt_task_wait_period() which i have fixed to rt_task_wait_period(NULL) and also gives me warning rt_start_time is deprecated and i have removed this line because in 2.2 system timer automatically starts but still by 
rt_task_set_periodic gives error   "system timer not stared" and my program exits due to return statement showing that peridodic mode is not set.i am attaching my code.Please figure out the problem and help me about the bug in program.Thanks all.

 
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.

[-- Attachment #1.2: Type: text/html, Size: 861 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 4248410318-doppel_task.c --]
[-- Type: text/x-csrc; name="doppel_task.c", Size: 4860 bytes --]

#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>


#define STACK_SIZE 8192
#define STD_PRIO1 2
#define STD_PRIO2 1

RT_TASK zaehler1_task_ptr;
RT_TASK zaehler2_task_ptr;
int count1 = 0;
int count2 = 0;
int i;
int end = 0;

//                      --s-ms-us-ns
RTIME task_period_ns1 =   1000000000llu;
RTIME task_period_ns2 =  10000000000llu;


void zaehler1_task(void *cookie){
        int ret;
        
// ************************* Xenomai-Krempel ********************************************************************
        ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns1));
     switch(-ret){
      case EINVAL:   printf("Task is not a task descriptor\n");
                    break;
      case EIDRM:  printf( "Task is a deleted task descriptor\n");
                    rt_task_sleep(50000); // wait 50us
                    break;
      case ETIMEDOUT: printf("idate different from TM_INFINITE\n");
                    break;
      case EWOULDBLOCK: printf("system timer not stared\n");
                    break;
      case EPERM:    printf("task is null\n");
      break;
    }   
     
      if (ret) {
                printf("error while set periodic, code %d\n",ret);
                return;
        }
// ************************* Ende Xenomai-Krempel ****************************************************************


// ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
        while(!end){
    /*      
          ret = rt_task_set_mode(0, T_PRIMARY, NULL);
                if (ret) {
                        printf("error while rt_task_set_mode, code %d\n",ret);
                        return;
                }
      */          
             ret = rt_task_wait_period(NULL);
                printf("T1:Start\n");

                if (ret) {
                        printf("error while rt_task_wait_period, code %d\n",ret);
                        return;
                }
                count1++;

                printf("T1:Ende:%d\n", count1);

                fflush(NULL);
        }
// ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
}


void zaehler2_task(void *cookie){
	int ret;	
	long ii;
	long jj;
	double a;
        unsigned long overrun;
// ************************* Xenomai-Krempel ********************************************************************
	ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns2));
	if (ret) {
		printf("error while set periodic, code %d\n",ret);
		return;
	}
// ************************* Ende Xenomai-Krempel ****************************************************************


// ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
	while(!end){
	/*	ret = rt_task_set_mode(0, T_PRIMARY, NULL);
		if (ret) {
			printf("error while rt_task_set_mode, code %d\n",ret);
			return;
		}
	 */	
      ret = rt_task_wait_period(NULL);
		
		printf("\t\tT2:Start\n");

		if (ret) {
			printf("error while rt_task_wait_period, code %d\n",ret);
			return;
		}

                for(ii=0; ii<200; ii++) {
		 	for(jj=0; jj<1000000; jj++) {
				a = (double)ii * (double)jj;
			}
		}              

                count2++;
                printf("\t\tT2:Ende:%d\n", count2++);

		fflush(NULL);
        }
// ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
}
       


// signal-handler, to ensure clean exit on Ctrl-C
void clean_exit(int dummy) {
	printf("cleanup\n");
	end = 1;
	rt_task_delete(&zaehler1_task_ptr);
	rt_task_delete(&zaehler2_task_ptr);
	printf("end\n");
}

int main(int argc, char *argv[]) {
	int err, ret;
	printf("start\n");
	// install signal handler
	signal(SIGTERM, clean_exit);	
	signal(SIGINT, clean_exit);	
	// start timer
	//ret = rt_timer_start(TM_ONESHOT);
/*	switch (ret) {
		case 0:       printf("Mit dem Fahrrad nich inn ersten Wagen\n\n");
		              break;
		case -EBUSY:  printf("timer is running\n");
		              break;
		case -ENOSYS: printf("can't start timer\n");
		              return ret;
	}

*/

	/* create zaehler1_task */
	err = rt_task_create(&zaehler1_task_ptr,"alpha",STACK_SIZE,STD_PRIO1,0);
	/* create zaehler2_task */
	err = rt_task_create(&zaehler2_task_ptr,"beta",STACK_SIZE,STD_PRIO2,0);

	/* start zaehler1_task */
	err = rt_task_start(&zaehler1_task_ptr,&zaehler1_task,NULL);

	/* start zaehler2_task */
	err = rt_task_start(&zaehler2_task_ptr,&zaehler2_task,NULL);

	// wait for signal & return of signal handler
	pause();
	fflush(NULL);
	return 0;
}

  parent reply	other threads:[~2006-11-30 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060927151753.9409.qmail@domain.hid>
2006-09-27 15:44 ` [Xenomai-help] Re: [Xenomai-core] aperiodic xenomai tasks Jan Kiszka
2006-10-05 13:57   ` [Xenomai-help] Problem with Aperiodic " mani bhatti
2006-11-30 16:45   ` mani bhatti [this message]
2006-12-03 15:02 [Xenomai-help] porting to kernel 2.2 mani bhatti
2006-12-03 17:44 ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061130164532.70291.qmail@domain.hid \
    --to=imranbashirbhatti@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.