Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
TEST5.C
Package: ertos.rar [view]
Upload User: sunrenlu
Upload Date: 2022-06-13
Package Size: 1419k
Code Size: 1k
Category:
OS Develop
Development Platform:
DOS
- /**************************************************************************/
- /* test5 - shows byte queue tools */
- /**************************************************************************/
- #include "rtos.h"
- #include <stdio.h>
- #include <stdlib.h>
- void *peer = NULL;
- bq_str *bq = NULL; /* byte queue */
- void switcher1(DWORD arg)
- {
- int x;
- #if defined(__TURBOC__)||defined(__BORLANDC__)
- randomize();
- #else
- srand( time( 0 ));
- #endif
- do {
- rt_yield();
- x = rand();
- if ( x > 25000 ) {
- x = ( x & 255 );
- cprintf( " sending %u ", x );
- bq_writebyte( bq, x );
- bq_writebyte( bq, x );
- bq_writebyte( bq, x );
- bq_writebyte( bq, x );
- bq_writebyte( bq, x );
- }
- } while ( 1 );
- }
- void switcher2(DWORD arg)
- {
- int x, cnt, i;
- do {
- rt_yield();
- cnt = bq_readcount( bq );
- if ( cnt == 0 ) cprintf(".");
- else for ( i = 0 ; i < cnt ; ++i ) {
- if ( bq_readbyte( bq , &x ))
- cprintf(" read %u rn", x );
- }
- } while ( 1 );
- }
- main()
- {
- kdebug = 1;
- rt_init(100);
- bq = bq_alloc( 100 );
- cputs("starting...rn");
- peer = rt_newthread( switcher2, 2,4096, 0, "worker 2" );
- rt_newthread( switcher1, 1,4096, 0, "worker 1" );
- rt_sleep( 10000 );
- }