在使用应用层定时器的一个问题

19 views
Skip to first unread message

PowerMan

unread,
Dec 16, 2008, 6:34:29 AM12/16/08
to RTEMS Chinese User Group
我的应用程序代码附在最后,主要问题是timer的服务例程
不能调用printf,否则程序就跑飞,而printk可以。
我的平台是rtems-4.7.3,s3c2410,因为我的板子和smdk2410差别很大,
所以没用最新的rtems-4.9.1,而是根据gp32(s3c2400)修改了一下。
因为我只做了少量修改,所以我猜想这个bug不是我导致的,因此
在rtems-4.9.1上会有同样的问题,有smdk2410的同志请帮我在4.9.1上验证一下。
app代码如下:

#include <bsp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rtems/bspIo.h>

static rtems_id timer_id;
static rtems_name timer_name;
static const char timer_name_s[8] = "tmr0";

static rtems_timer_service_routine timer_show(rtems_id tid, void
*pdat)
{
printk("aa");
printf("bb");
printk("cc");
}

static int init_timer(void)
{
/* build object name for timer */
timer_name = rtems_build_name(timer_name_s[0], timer_name_s[1],
timer_name_s[2], timer_name_s[3]);

/* create timer */
if (rtems_timer_create(timer_name, &timer_id) != RTEMS_SUCCESSFUL) {
fprintf(stderr, "failed to create timer\n");
return 0;
}

/* fire after 5 seconds */
rtems_timer_fire_after(timer_id, 500, timer_show, NULL);

return 1;
}

rtems_task Init(rtems_task_argument argument)
{
if (!init_timer()) {
fprintf(stderr, "failed to init timer\n");
exit(0);
}

for (;;);

if (rtems_task_delete(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
fprintf(stderr, "failed to delete init-task\n");
exit(0);
}
}

/**************** START OF CONFIGURATION INFORMATION ****************/

#define CONFIGURE_INIT

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_TIMERS 10

#define CONFIGURE_TICKS_PER_TIMESLICE 10

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#include <rtems/confdefs.h>

/**************** END OF CONFIGURATION INFORMATION ****************/

xu ray

unread,
Dec 16, 2008, 11:07:02 AM12/16/08
to rtems-chines...@googlegroups.com
给的信息比较少,很难给出准确答案
首先,ticker程序在你的板子上能否运行?
如果5秒触发一次,那么每次触发过程中,printf是不会被打断的,那么说明和线程切换应该没有关系。

2008/12/16 PowerMan <power...@gmail.com>



--
Thanks & Best Regards!

Ray, Xu

PowerMan

unread,
Dec 16, 2008, 8:28:18 PM12/16/08
to RTEMS Chinese User Group
没有printf,只有printk是可以正常运行的;
而且这个application在pc上(pc386)printk,printf都可以,但arm上不行;
我想请帮忙是一下在smdk2410是否可以。是否和我的现象一样--只要不调printf,干什么都可以。

On 12月17日, 上午12时07分, "xu ray" <rayx...@gmail.com> wrote:
> 给的信息比较少,很难给出准确答案
> 首先,ticker程序在你的板子上能否运行?
> 如果5秒触发一次,那么每次触发过程中,printf是不会被打断的,那么说明和线程切换应该没有关系。
>

> 2008/12/16 PowerMan <powerman...@gmail.com>

xu ray

unread,
Dec 17, 2008, 10:07:35 AM12/17/08
to rtems-chines...@googlegroups.com
我的smdk2410板子送人了。不过我在qemu和skyeye上面模拟2410的printf是没有问题的...
ARM7的我测试过没有问题。

2008/12/17 PowerMan <power...@gmail.com>
Reply all
Reply to author
Forward
0 new messages