WATCOM C Library Reference : bdos, _beginthread, bessel Funtions, _bfreeseg

 

 

 

 

bdos

 

Synopsis : #include <dos.h>

              int bdos ( int dos_func, unsigned dx, unsigned char al ); 

Description : The bdos function causes the computer's central processor (CPU) to be interrupted with an
interrupt number hexadecimal 21 (0x21), which is a request to invoke a specific DOS function. Before the interrupt, the DX register is loaded from dx, the AH register loaded with the DOS function number from dos_func and the AL register is loaded from al. The remaining registers are passed unchanged to DOS.


You should consult the technical documentation for the DOS operating system you are using to determine the expected register contents before and after the interrupt in question.


Returns : The function returns the value of the AX register after the interrupt has completed.

See Also : int386, int386x, int86, int86x, intdos, intdosx, intr, segread

Example :

#include <dos.h>
#define DISPLAY_OUTPUT   2


void main( )

{

    int rc;
    rc = bdos ( DISPLAY_OUTPUT, 'B', 0 );

    rc = bdos ( DISPLAY_OUTPUT, 'D', 0 );

    rc = bdos ( DISPLAY_OUTPUT, 'O', 0 );

    rc = bdos ( DISPLAY_OUTPUT, 'S', 0 );

}

 

Classification : DOS
Systems : DOS, Win, NT, DOS/PM

 

 

 

_beginthread

 

Synopsis : #include <process.h> 

              int far beginthread (

                  void (__far *start_address) (void __far *),

                  void __far *stack bottom,

                  unsigned stack_size,

                  void __far *arglist );


Description : The _beginthread function uses the OS/2 function DosCreateThread to begin a new thread of execution at the function identified by start_address with a single parameter identified by arglist.

 

The new thread will use the memory identified by stack_bottom and stack_size for its stack.


Note for 16-bit applications : If the stack is not in DGROUP (i.e., the stack pointer doe point to an area in DGROUP) then you must compile your application with the "zu" option.

 

For example, the pointer returned by malloc in a large data model may not be in DGROUP. The "zu" option relaxes the restriction that the SS register contains the base address of the default data segment, "DGROUP".

 

Normally, all data items are placed into the group DGROUP and the SS register contains the base address of this group. In a thread the SS register will likely not contain the base address of this group. When the "zu" option is selected, the SS register is volatile (assumed to point to another segment) and any global data references require loading a segment register such as DS with the base address of DGROUP.


The thread ends when it exits from its main function or calls exit_exit or _endthread.


Returns : The _beginthread function returns the thread id for the new thread if successful. A return value of -1 indicates that the thread could not be started.

See Also : _endthread

Example :
#include <stdio.h> 

#include <stdlib.h> 

#include <process.h>
#define STACK_SIZE    4096

 

#if defined (__386__)
    #define FAR

#else
    #define FAR __far

#endif


void FAR child( void FAR *parm )

{
    char *FAR *argv = (char * FAR *) parm;

    int i;
    for (i = 0; argv[i]; i++) {
        printf( "argv[%d] = %s\n", i, argv[i] );

    }
    _endthread( );

}

 

void main( )

{
    char *stack;

    char *args[3];

    int tid;


    args [0] = "child";

    args [1] = "parm";

    args [2] = NULL;

    stack = (char *) malloc( STACK_SIZE );

    tid = _beginthread ( child, stack, STACK_SIZE, args );

}

 

Classification : OS/2
Systems : OS/2 1.x(MT), OS/2 1.x(DL), OS/2 2.x, NT


 

 

bessel Funtions

 

Synopsis : #include <math.h>

              double j0( double x );

              double j1( double x );

              double jn( int n, double x );

              double y0 ( double x );

              double y1( double x );

              double yn ( int n, double x );

Description : Functions j0, j1, and jn return Bessel functions of the first kind.


Functions y0y1, and yn return Bessel functions of the second kind. The argument x must be positive. If x is negative, _matherr will be called to print a DOMAIN error message to stderr, set errno to EDOM, and return the value -HUGE_VAL. This error handling can be modified by using the matherr routine.


Returns : These functions return the result of the desired Bessel function of x.

See Also : matherr

Example :
#include <stdio.h> 

#include <math.h>

 

void main( )

{
    double x, y, z;
    x = j0( 2.4 );

    y = y1( 1.58 );

    z = jn( 3, 2.4 );

    printf( "j0(2.4) = %f, y1(1.58) = %f\n", x, y );

    printf( "jn(3, 2.4) = %f\n", z);

}

 

Classification : WATCOM
Systems : j0, j1, jn, y0, y1, yn = All

 

 

 

_bfreeseg

 

Synopsis : #include <malloc.h> 

              int _bfreeseg ( __segment seg );

Description : The _bfreeseg function frees a based-heap segment.
The argument seg indicates the segment returned by an earlier call to _bheapseg.


Returns : The bfreeseg function returns 0 if successful and -1 if an error occurred.

See Also : bcalloc, bexpand, bfree, bheapseg, bmalloc, brealloc

Example :
#include <stdio.h> 

#include <stdlib.h> 

#include <malloc.h>


struct list {
    struct list __based( __self ) *next;

    int value; 

};


void main( )

{
    int   i; 

    __segment seg;

    struct list __based(seg) *head;

    struct list __based(seg) *p;


    /* allocate based heap */ 

    seg = _bheapseg ( 1024 ); 

    if( seg == _NULLSEG ) {
        printf( "Unable to allocate based heap\n" );

        exit(1);

    }


    /* create a linked list in the based heap */ 

    head = 0; 

    for( i = 1; i < 10; i++ ) {
        p = _bmalloc( seg, sizeof( struct list ) );

        if ( p == NULLOFF ) {
            printf( "_bmalloc failed\n" );

            break;

        }
        p->next = head;

        p->value = i;

        head = p;

    }


    /* traverse the linked list, printing out values */ 

    for ( p = head; p != 0; p = p->next ) {
        printf( "Value = %d\n", p->value);

    }

    /* free all the elements of the linked list */

    for( ; p = head; ) {

        head = p->next;

        _bfree( seg, p );

    }
    /* free the based heap */

    _bfreeseg( seg );

}

 

 

Classification : WATCOM
Systems : DOS/16, Win/16, QNX/16, OS/2 1.x(all)

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,