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

📄 proc1.cc

📁 Murphy 大俠 GPL 的 C++/x86 RTOS, 支持 MMU, 用戶/核心 模式區隔. http://hpc.ee.ntu.edu.tw/~murphy/me/EKernel.html
💻 CC
字号:
extern inline void cli() { asm volatile("cli"); }

typedef unsigned long dword;

#include "stdio.h"
#include "SystemCallLib.h"

char stack_thread1[1024];

void Thread1(void);

dword nSemaphoreID;
dword nMessageQueueID;

void main()
{

	dword nThreadID;

	printf("Enter main() of proc1\n");

	CreateSemaphore(&nSemaphoreID, "Semaphore1", 1);

	CreateThread(&nThreadID, "Thread1", Thread1, stack_thread1, 1024, true);

	dword ret=CreateMessageQueue(&nMessageQueueID, "MsgQ1", 10);

	printf("proc1 main thread create message queue ret = %x\n", ret);

	while(1)
	{
		dword nMessage;
		dword nParam1;
		dword nParam2;
		GetMessage(nMessageQueueID, &nMessage, &nParam1, &nParam2, true);
		SerialPutchar(nMessage);
		WaitSemaphore(nSemaphoreID, true);
		SerialPutchar('m');
		SerialPutchar('a');
		SerialPutchar('i');
		SerialPutchar('n');
		SerialPutchar('1');
		SerialPutchar('\n');
		SignalSemaphore(nSemaphoreID);
		for(int i=0;i<0x300000;i++);

	};
}

void Thread1(void)
{
//	printf("proc1 thread1 semaphore ID = %d\n", nSemaphoreID);

	char i='A';
	while(1)
	{
		SendMessage(nMessageQueueID, (dword)i, 0, 0, true);
		i++;
		if(i>'Z')
			i='A';
		WaitSemaphore(nSemaphoreID, true);
		SerialPutchar('t');
		SerialPutchar('h');
		SerialPutchar('r');
		SerialPutchar('d');
		SerialPutchar('1');
		SerialPutchar('\n');
		SignalSemaphore(nSemaphoreID);
		for(int i=0;i<0x300000;i++);
	};
}

⌨️ 快捷键说明

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