User`s guide
Cray XMT™ Programming Environment User’s Guide
memset(testBuffer, 0, DEFAULT_BUFFER_SIZE);
// Restore a snapshot dataset from disk back into memory.
err = dslr_restore ((char *)DEFAULT_FILENAME, testBuffer,
DEFAULT_BUFFER_SIZE, &snapError);
if (dslr_ERR_OK != err)
{
fprintf(stderr,"Failed to restore the dataset. Error %d.\n",err);
free(testBuffer);
return -1;
}
// At this point, the testBuffer should be full of 'a'
free(testBuffer);
return 0;
}
Example 15. Using dslr_pwrite to write data to a file and dslr_pread to read
back the data
Note that the calls to dslr_pwrite and dslr_pread accept the value
dslr_ANY_SW to specify the endpoint ID of the fsworker, allowing libsnapshot
to use any registered endpoint. Therefore, the fsworkerID is automatically set to
dslr_ANY_SW rather than requiring the user to enter the endpoint either manually
or by the environment.
Also note that, while the function call interface appears to invite parallel use of
dslr_pwrite and dslr_pread, the functions cannot be used in parallel.
Concurrent calls to these or any other snapshot library functions results in the
problems described in the caution statement above. Regardless of how the endpoint is
set, only one thread of one instance of fsworker will be applied to any given call
to dslr_pwrite and dslr_pread.
72 S–2479–20