TEST18.C
资源名称:ertos.rar [点击查看]
上传用户:sunrenlu
上传日期:2022-06-13
资源大小:1419k
文件大小:1k
源码类别:
操作系统开发
开发平台:
DOS
- #include <stdio.h>
- #include <rtos.h>
- #include <conio.h>
- /*
- * Demonstrate buffer overrun detection
- */
- #if defined(__TURBOC__) || defined(__BORLANDC__)
- #define STACKLEN 2048
- #else
- #define STACKLEN 4096
- #endif
- /*********************************************************/
- void test(DWORD arg)
- {
- char *p;
- #define TESTSIZE 512
- p = kcalloc( TESTSIZE, 1 );
- if ( p != NULL ) {
- memset( p, 0, TESTSIZE + 1 );
- kfree( p );
- }
- }
- /*********************************************************/
- int main(int argc, char **argv)
- {
- int i;
- // changing the next line would all that is needed to make this
- // a pre-emptive multithreaded application
- kpreemptive = 0;
- kdebug = 1;
- rt_init(100);
- kwindow( 1, 6, 80, 16 );
- cputs("Will demonstrate capturing a buffer overrunrn");
- cputs("starting...rn");
- rt_newthread( test, 1,4096, 0, "worker 1" );
- for ( i = 0 ; i < 1000 ; ++i ) {
- rt_sleep( 10 );
- cprintf("in main %inr", i);
- }
- }