⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello.c

📁 < 嵌入式系统编程>>源代码解析光盘,包括这本书各章节的示例代码(无密码)
💻 C
字号:
#include <rtl.h>
#include <time.h>
#include <pthread.h>
pthread_t thread;
//The execution thread is embodied in the hello function
void * hello()
{
	struct sched_param p;
	//assigning the thread with a scheduling priority 1
	p . sched_priority = 1;
	//this sets the scheduler behavior to be SCHED_FIFO for all subsequent execution
	pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);

	while (1) {
		//it blocks all further execution of the thread until the schedular calls it again
		for(i=1;i<=10;i++)
		{
			pthread_wait_np ();
		}
		rtl_printf("hello world");
	}
	return 0;
}
/* This module begins the entire process by creating an execution thread with init_module */

int init_module(void) {
	//it creates the thread
	return pthread_create (&thread, NULL, hello, 0);
}
/* This module ends the entire process by clearing the  execution thread with cleanup_module */

void cleanup_module(void) {
	//it delete the realtime thread
	pthread_delete_np (thread);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -