hello.c
来自「fsmlabs的real time linux的内核」· C语言 代码 · 共 57 行
C
57 行
/* * RTLinux Hello World example * * Written by Michael Barabanov (baraban@fsmlabs.com) * Copyright (C) 1999-2000 Finite State Machine Labs Inc * Released under the terms of the GPL Version 2 * */#include <rtl_sync.h>#include <rtl.h>#include <time.h>#include <pthread.h>#include <rtl_debug.h>pthread_t thread = 0;pthread_t thread2 = 0;void * start_routine(void *arg){ int i; struct sched_param p; volatile pthread_t self; self = pthread_self(); p . sched_priority = 1; pthread_setschedparam (pthread_self(), SCHED_FIFO, &p); pthread_make_periodic_np (pthread_self(), gethrtime(), 500000000); if (((int) arg) == 1) { breakpoint(); } for (i = 0; i < 20; i ++) { pthread_wait_np (); rtl_printf("I'm here; my arg is %x\n", (unsigned) arg); } return 0;}int init_module(void){ pthread_create (&thread, NULL, start_routine, (void *) 1); return pthread_create (&thread2, NULL, start_routine, (void *) 2);}void cleanup_module(void){ pthread_cancel (thread); pthread_join (thread, NULL); pthread_delete_np (thread2);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?