📄 readme.txt
字号:
03-Jan-01 David Poole davep@mbuf.com0. Paranoia.I'm providing this chunk of code in the hopes that it will be useful to otherfolks as they come up to speed on using uCOS-II. An embedded system is anunforgiving learning environment so I created these functions to allow me towork the kinks out of our product under Linux.Any possible usefulness of this code is purely coincidental. If it breaks,don't act too surprised.1. Introduction.See linuxucos.c for descriptions of uCOS-II functions that are currentlyimplemented. There are currently only 14 of the many uCOS-II functionsimplemented. 2. History13-Dec-01 Initial "release" as 'fakeucos'01-Jan-01 Added support for OSFlagAccept(), OSFlagCreate(), OSFlagPend() and OSFlagPost(). Renamed to 'linuxucos'3. Integration with uCOS-II.None of the actual uCOS-II source code is compiled. linuxucos replaces thefunctions of uCOS-II with its own built on SysV IPC and POSIX threadsmechanisms.Normally porting uCOS-II to a new product (not platform) requires hits to os_cfg.h. The only thing required in os_cfg.h is #define OS_TICKS_PER_SEC 1000 /* Set the number of ticks in one second */as linuxucos uses a 1ms tick on Linux. (See OSTimeGet().)No changes are required to os_cpu.h as only the typedef's are used.Please note that I've tried very hard to maintain the functional similaritybetween linuxucos and uCOS-II. To the best I could, the functions willbehave the same under Linux as under uCOS-II. I've had to sacrifice someperformance under Linux (polling on semaphores, for example) to maintain the functional similarity. - polling on SysV semaphores (OSMutex???()) - polling on SysV message queues (OSQ???()) - each OSFlagPost() wakes up *all* sleeping threads; it is the sleeping threads' responsiblity to verify its flags (in uCOS-II, the caller verifies the flags before waking the sleeping threads)4. Changes.Changes to uCOS-II core code:ucos_ii.h The return type of the task function ptr passed to OSTaskCreate() and OSTaskCreateExt() is different between POSIX threads and uCOS-II (void *) vs (void). A new #def THREAD is used to switch between the two definitions. FAKE_UCOS must be defined before includes.h is included to use the new pthreads return type. All tasks that are to be portable between Linux and uCOS-II must have return type THREAD. In source file linuxucos.c: #include "includes.h" THREAD task1( void *arg ) { while( 1 ) { // do things } } int main( void ) { ... os_err = OSTaskCreate( task1, (void *)1, task1_stack, TASK1_PRIO ); ... } In the Makefile: linuxucos : linuxucos.c $(CC) $(CFLAGS) -DLINUX_UCOS $< -o $@ -lpthread
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -