/* * Copyright (C) 2005 Niklaus Giger . * * vxWorks is a registered trademark of Wind River Systems, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Hopefully this program lets you compare the relative performance of * taskSwitches and message passing between an original vxWorks image and * a xenomai based port. */ #ifdef XENOMAI #include #include #include MODULE_LICENSE("GPL"); #else #include #include #include #include #include #include #define xnprintf printf #define taskExit exit #define RTIME UINT64 RTIME rt_timer_tsc(); RTIME rt_timer_tsc() { UINT32 low, high; UINT64 res; vxTimeBaseGet (&low, &high); res = (UINT64) low + ((UINT64) high)<<32; return res; } #endif #define TASK_PRI 115 #define STACK_SIZE 8192 MSG_Q_ID question_qid, answer_qid; int producer_tid, consumer_tid, test_tid; static int nrQuestions; static int nrAnswers; static int nrSwitches; void reportState(const char *where) { xnprintf("%s nrQuestions %d nrAnswers %d nrSwitches %d\n", where, nrQuestions, nrAnswers, nrSwitches); } #define NR_RUNS 100 void task1 (int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) { int msg; int sz; int j; RTIME diff, startTime, endTime; xnprintf("task1 started\n"); startTime = rt_timer_tsc(); for (j=0; j