Annotation of os2sdk/demos/examples/asyncio/asyncio.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Example of DOSWRITEASYNC. (DOSREADASYNC is not demonstrated,
                      3:  * but has identical usage).
                      4:  *
                      5:  * In this example, the program uses DOSWRITEASYNC to write a
                      6:  * large block of data to the screen asynchronously, while the
                      7:  * main program sits in a loop beeping.
                      8:  *
                      9:  * Compile as: cl -AL -G2 -Lp async.c
                     10:  *
                     11:  * Copyright (C) Microsoft Corp. 1986
                     12:  */
                     13: 
                     14: #include <doscalls.h>
                     15: 
                     16: #define FREQ 440
                     17: #define DURATION 500L
                     18: 
                     19: char cbuf[10 * 1024];          /* buffer to write from */
                     20: long sem;                      /* ram semaphore */
                     21: 
                     22: main()
                     23: {
                     24:        int i;
                     25:        unsigned rc;            /* return code */
                     26:        unsigned bytecount;     /* bytes written */
                     27: 
                     28:        for(i = 0; i < sizeof(cbuf); i++)       /* init buffer */
                     29:                cbuf[i] = 'x';
                     30: 
                     31:        sem = 0;
                     32:        DOSSEMSET((unsigned long)&sem);         /* set semaphore */
                     33:        DOSWRITEASYNC(1,&sem,&rc,cbuf,sizeof(cbuf),&bytecount);
                     34: 
                     35:        for(i = 0; i < 10; i++) {
                     36:                DOSBEEP(FREQ, DURATION);
                     37:                DOSSLEEP(DURATION);
                     38:        }
                     39: 
                     40:        DOSSEMWAIT((unsigned long)&sem, -1L);
                     41:        printf("return code = %d, bytes written = %d\n", rc, bytecount);
                     42: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.