- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- POSIX IO atomicity
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2010 05:38 AM
тАО06-17-2010 05:38 AM
I read this -
Posix standard defines atomiciy such that all bytes from single file I/O request
that starts our together ends up together, without interleaving from other I/O requests.
What does this mean.
Example -
consider file has 100 blocks.
Reader reads blocks 1 to 100
and at the same time
Writer writes blocks 1 to 100
Question 1
In this case, Reader should get all 100 blocks of old data (before write)
or all 100 blocks of new data(after write), not mix data.
Is this correct ?
Question 2
What is the maximum size for which the atomicity is garunteed.
in the above example if the reader/writer were to read/write 10000
blocks, even then the atomicty rule will apply ?
is there a maximum limit for the atomicity ?
please advise
Scotty
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2010 08:47 PM
тАО06-17-2010 08:47 PM
Re: POSIX IO atomicity
Seems reasonable.
>Q2: What is the maximum size for which the atomicity is guaranteed. ... is there a maximum limit for the atomicity?
For pipes it is about 8 Kb, PIPE_MAX(5).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 07:22 AM
тАО06-24-2010 07:22 AM
Re: POSIX IO atomicity
for question 2, i mean system calls write/read...
Scotty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 12:24 PM
тАО06-24-2010 12:24 PM
SolutionBoth read(3posix) and write(3posix) have this sentence:
---
If the value of _nbyte_ is greater than {SSIZE_MAX}, the result is implementation-defined.
---
Note: nbyte is the parameter in the read()/write() system call that determines the number of bytes to read/write.
I'm not a programming guru, but I would understand it like this:
A single read()/write() system call, with a data size of SSIZE_MAX bytes or less, is guaranteed to be atomic by POSIX.
If you try to read/write a larger piece than that in one system call, what happens will depend on the platform you're on. It may be rejected outright, or the system might accept it; if the system accepts it, it may or may not be an atomic operation.
If you run two separate read()/write() calls, that is clearly two separate I/O requests, and interleaving may happen between them.
A bit of Googling seems to indicate that you might generally expect SSIZE_MAX to be at least 32767 bytes, but it could be a lot more on some platforms.
http://www.pasc.org/interps/unofficial/db/p1003.1/pasc-1003.1-29.html
Since SSIZE_MAX seems to be a compile-time constant, if your program is supposed to be portable, you might put in some pre-processor directives like this if you need larger than 32kB atomic I/O requests:
#if (SSIZE_MAX < [required_size])
#then
#error "Oh noes! This system cannot do atomic reads/writes of [required_size]. Implement some file locking or something..."
#endif
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2010 01:41 AM
тАО06-25-2010 01:41 AM
Re: POSIX IO atomicity
Yes, and if you read/write to a pipe, you are limited. Don't know about regular disk files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-09-2010 06:38 AM
тАО07-09-2010 06:38 AM
Re: POSIX IO atomicity
if io size is less than SSIZE_MAX then OS garuntees atomicity
otherwise its implementation defined (OS has the right to deal it
in its own way)
Scotty