Re: using a pfNewDPool between unrelated processes

New Message Reply Date view Thread view Subject view Author view

Jim Helman (jimh++at++surreal)
Thu, 04 Nov 93 14:12:55 -0800


It should work. Try the following simple test program.

        dpool create &
        dpool attach &

Also check the permissions on the file created in /usr/tmp or
try running as root. It could be a umask issue.

rgds,

-jim helman

jimh++at++surreal.asd.sgi.com
415/390-1151

#include <stdio.h>
#include "pr.h"

int
main(int argc, char *argv[])
{
    pfDataPool *dpool;
    char *name = "dpooltest";
    long *ptr;

    if (argc < 2)
        goto usage;

    if (argv[1][0] == 'c')
    {
        printf("creating dpool %s\n", name);
        dpool = pfNewDPool(1024, name);
        if (dpool == NULL)
        {
            perror("couldn't create dpool");
            exit(-1);
        }
        ptr = (long *) pfDPoolAlloc(dpool, 16, 5);
        if (ptr == NULL)
        {
            perror("couldn't alloc from dpool");
            exit(-1);
        }
        while (1)
        {
            pfDPoolLock(ptr);
            (*ptr)++;
            pfDPoolUnlock(ptr);
            fprintf(stderr, "%d\n", *ptr);
        }
        exit(0);
    }
    else if (argv[1][0] == 'a')
    {
        printf("attaching to dpool %s\n", name);
        dpool = pfAttachDPool(name);
        if (dpool == NULL)
        {
            perror("couldn't attach to dpool");
            exit(-1);
        }
        ptr = (long *)pfDPoolFind(dpool, 5);
        if (ptr == NULL)
        {
            perror("couldn't find ID in dpool");
            exit(-1);
        }
        while (1)
        {
            pfDPoolLock(ptr);
            *ptr = - *ptr;
            pfDPoolUnlock(ptr);
        }
        exit(0);
    }
    else
    {
    usage:
        printf("usage: dpool.fun [create|attach]\n");
        exit(-1);
    }
}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:05 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.