- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- second call to shmat in same process
Operating System - HP-UX
1819794
Members
3220
Online
109607
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО01-17-2008 01:45 AM
тАО01-17-2008 01:45 AM
second call to shmat in same process
If the calling process is already attached to the shared memory segment, shmat() fails and returns SHM_FAILED regardless of what value is passed in shmaddr.
This is not done in other *NIX platforms.
Is there any mechanism to know this is already attached by someone in the process and if yes how to know the address to which it is attached , so that I can use it.
I really don't want to make shared memory point global now.
#include
#include
#include
#include
extern int errno ;
int main()
{
int id = -1 , id2;
key_t key = ftok("/PRAMODTEST" , 700);
id = shmget(key , 16 , 0600 | IPC_CREAT);
if( -1 != id)
{
void *sharedMem = shmat( id ,NULL ,SHM_RDONLY) ;
if((int)sharedMem == -1 )
{
printf("Attaching failed %d , %s \n" , errno , strerror(errno) );
}
else
{
void *p = shmat(id ,NULL ,0) ;
if((int)p == -1 )
{
printf("Second attach is failed %d , %s \n" , errno , strerror(errno));
}
else
{
printf("Second attach paased\n");
shm_unlink("/PRAMODTEST");
}
shmdt(sharedMem);
}
}
else
printf("shmget failde\n");
}
Thanks in advance.
This is not done in other *NIX platforms.
Is there any mechanism to know this is already attached by someone in the process and if yes how to know the address to which it is attached , so that I can use it.
I really don't want to make shared memory point global now.
#include
#include
#include
#include
extern int errno ;
int main()
{
int id = -1 , id2;
key_t key = ftok("/PRAMODTEST" , 700);
id = shmget(key , 16 , 0600 | IPC_CREAT);
if( -1 != id)
{
void *sharedMem = shmat( id ,NULL ,SHM_RDONLY) ;
if((int)sharedMem == -1 )
{
printf("Attaching failed %d , %s \n" , errno , strerror(errno) );
}
else
{
void *p = shmat(id ,NULL ,0) ;
if((int)p == -1 )
{
printf("Second attach is failed %d , %s \n" , errno , strerror(errno));
}
else
{
printf("Second attach paased\n");
shm_unlink("/PRAMODTEST");
}
shmdt(sharedMem);
}
}
else
printf("shmget failde\n");
}
Thanks in advance.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2008 04:02 AM
тАО01-17-2008 04:02 AM
Re: second call to shmat in same process
Yes, that's in the man page and all:
"If the calling process is already attached to the shared memory segment, shmat() fails and returns SHM_FAILED regardless of what value is passed in shmaddr. See exceptions for MPAS processes below."
Quickly skimming over the gory details, this differs from other OS's because HP-UX is a Mostly Global Address Space, they're Mostly (or Completely) Private. And that's because PA doesn't allow (easily) multiple virtual addresses at the same time for the same physical memory (aliasing).
Keep track of things within your own process (as you've considered and which I really think is the best option) or restrict yourself to 11iv2 and higher, IPF only and use MPAS (keeping in mind that using MPAS too much and generating a _lot_ of aliases slows down the system as a whole [because of the collision chains in the translation tables]).
"If the calling process is already attached to the shared memory segment, shmat() fails and returns SHM_FAILED regardless of what value is passed in shmaddr. See exceptions for MPAS processes below."
Quickly skimming over the gory details, this differs from other OS's because HP-UX is a Mostly Global Address Space, they're Mostly (or Completely) Private. And that's because PA doesn't allow (easily) multiple virtual addresses at the same time for the same physical memory (aliasing).
Keep track of things within your own process (as you've considered and which I really think is the best option) or restrict yourself to 11iv2 and higher, IPF only and use MPAS (keeping in mind that using MPAS too much and generating a _lot_ of aliases slows down the system as a whole [because of the collision chains in the translation tables]).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2008 08:04 PM
тАО01-17-2008 08:04 PM
Re: second call to shmat in same process
Closing thread.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP