- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- pthread_mutex_init failing on HPUX 11i
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
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
тАО03-08-2005 12:44 PM
тАО03-08-2005 12:44 PM
I am using HPUX 11i(32-bit) with gcc version 3.4.2.
I have a program which forks processes.
The Mutex initialization/deletion is done in the parent process and the locking/Unlocking is done in the child process.
int nReturn = pthread_mutexattr_init(&attrMtx);
nreturn = pthread_mutex_init(SearchLock1, &attrMtx );
nReturn = pthread_mutexattr_destroy(&attrMtx);
pthread_mutex_init is returning EINVAL during Init.
I even tried putting the whole block inside pthread_once() but it still fails.
Any clue!!!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2005 01:35 PM
тАО03-08-2005 01:35 PM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2005 03:25 PM
тАО03-08-2005 03:25 PM
Re: pthread_mutex_init failing on HPUX 11i
Thanks for the clue. That works now but i am still struck :)
i have a small code that spawns child processes and each of the child process increments a global var.
int retval = pthread_mutex_lock(&SearchLockspd11) ;
for(int i=0; i < 10; i++)
{
g_GlobaInt++;
sleep(1);
}
retval= pthread_mutex_unlock(&SearchLockspd11) ;
Although the return value of Lock and Unlock are 0, the Lock is not happening.
I mean as per the code above it should print all 10 values for g_GlobaInt for process1 and then should go ahead with process2. But currently i am able to see a mix of both the processes in the logs. Is there something wrong which i am doing???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2005 03:40 PM
тАО03-08-2005 03:40 PM
Re: pthread_mutex_init failing on HPUX 11i
#include
#include
#include
#include
#include
#include
typedef pthread_mutex_t *LPCRITICAL_SECTION;
typedef pthread_mutex_t CRITICAL_SECTION;
int g_Val=0;
int ThreadID =0;
int ThreadIDChild =0;
static pthread_mutex_t SearchLockspd11; // = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static pthread_once_t once_control1 = PTHREAD_ONCE_INIT;
void initialize123()
{
int nreturn = 0;
pthread_mutexattr_t attrMtx;
int nReturn = pthread_mutexattr_init(&attrMtx);
nreturn = pthread_mutex_init(&SearchLockspd11, &attrMtx );
nReturn = pthread_mutexattr_destroy(&attrMtx);
}
void initialize1()
{
pthread_mutex_destroy(&SearchLockspd11);
}
main()
{
printf("ENOSYS = %d\n", ENOSYS);
int i = 0;
int j = 0;
int nTemp=0;
pthread_once(&once_control, initialize123);
ThreadID = getpid();
printf("Original....PID is %d, PPID is %d\n", getpid(), getppid());
for(i=0; i < 50; i++)
{
if(getpid() == ThreadID)
{
fork();
if(getppid() == ThreadID)
{
nTemp = pthread_mutex_lock(&SearchLockspd11);
for(j=0; j<5;j++)
incrementCount();
nTemp = pthread_mutex_unlock(&SearchLockspd11);
exit(0);
}
else
{
if(getppid() == ThreadID)
{
exit(0);
i--;
}
}
}
else
{
exit(0);
i--;
}
}
pthread_once(&once_control1, initialize1);
exit(0);
return;
}
int incrementCount()
{
int nTemp=0;
g_Val++;
sleep(1);
}
~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-08-2005 08:45 PM
тАО03-08-2005 08:45 PM