DmWrite is atomic (it uses a system semaphore).  You could just structure
your code so that your record is constructed on the heap, then written to
data memory with a single DmWrite.  If you need to do in-place editing,
initialize your header to an invalid value first, record your data, then
write your valid data using a single DmWrite call last.  Then check for a
valid header before using the record.

Good Luck,
-jjf

-----Original Message-----
From: Shannon [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 19, 2000 9:57 AM
To: Palm Developer Forum
Subject: Semaphores


How do we handle data integrity issues with semaphores?

For example, lets say you are writing data to a database, and you also want
to write a size to the database as well. 

I currently allocate the memory, write the data, then write the size.

However, since the OS is multi-threaded, the pager card, for example, could
interrupt into the middle of this operation, add data to the storage memory,
potentially fill up storage memory or crash, and then I am left with only
the first write operation and not the second, and therefore corrupt data.

Are there any OS calls to prevent an interrupt at this level?

Shannon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hands High Software, Inc.

Award winning software for the Palm OS platform 

<http://www.handshigh.com/> 

[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to