Please help...
To make it simple, I have a simple test C program which calls my
semphore library functions only. (It doesn't call any db2 function at
all). And the following is the test program:
#include "hasem.h"
#include <semaphore.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
haSem hasem;
int val;
if (argc != 2)
{
printf("usage: semgetvalue <name>\n");
exit(1);
}
strcpy(hasem.se mName, argv[1]);
//Creating binary semaphore
//if (!semCreate(&ha sem))
//Creating counting semaphore
if (!semCreateCoun ting(&hasem,1))
{
printf("Failed to create semaphore\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 1)\n");
}
else
{
printf("value = %d(try 1)\n", val);
}
/*************** */
if (!semWait(&hase m)) // sem_wait() wrapper function
{
printf("Failed to secure semaphore.\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 2)\n");
}
else
{
printf("value = %d(try 2)\n", val);
}
/*************** */
if (!semPost(&hase m)) //sem_post() wrapper function
{
printf("Failed to post semaphore.\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 3)\n");
}
else
{
printf("value = %d(try 3)\n", val);
}
if (!semDestroy(&h asem))
{
printf("Failed to unlink semDestroy().\n ");
}
exit(0);
}
Without link to libdb2 the result is:
(gcc -g -O2 -D_REENTRANT -Wall -D__EXTENSIONS__ -I ~qq/rxgui/inc -c -o
hursemgetvalue. o hursemgetvalue. c
gcc -g -O2 -D_REENTRANT -Wall -D__EXTENSIONS__ -o hursemgetvalue
hursemgetvalue. o ~qq/rxgui/S*/obj/libhasem.a -lrt -lposix4 )
value = 1(try 1)
value = 0(try 2)
value = 1(try 3)
But if I link to libdb2 as well, the executable runs with incorrect
behavior. And the following is the printf output:
(gcc -g -Wall -I ~qq/rxgui/inc -c -o hursemgetvalue. o hursemgetvalue. c
gcc -o hursemgetvalue hursemgetvalue. o ~qq/rxgui/S*/obj/libhasem.a
-lrt -lposix4 -R/export/home/db2eee1a/sqllib/lib -ldb2)
value = 0(try 1)
value = 0(try 2)
value = 0(try 3)
As you can see, the semaphore value is always 0 and doesn't perform
locking function as well. I don't know if it's a DB2 bug or me making
a mistake somewhere. Any help or direction is greatly appreciated.
The DB2 SDK version is 7.2.9 on Solaris 8 and I am using gcc compiler. 1 2272
cranfic wrote:
Please help...
To make it simple, I have a simple test C program which calls my
semphore library functions only. (It doesn't call any db2 function at
all). And the following is the test program:
#include "hasem.h"
#include <semaphore.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
haSem hasem;
int val;
if (argc != 2)
{
printf("usage: semgetvalue <name>\n");
exit(1);
}
strcpy(hasem.se mName, argv[1]);
//Creating binary semaphore
//if (!semCreate(&ha sem))
//Creating counting semaphore
if (!semCreateCoun ting(&hasem,1))
{
printf("Failed to create semaphore\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 1)\n");
}
else
{
printf("value = %d(try 1)\n", val);
}
/*************** */
if (!semWait(&hase m)) // sem_wait() wrapper function
{
printf("Failed to secure semaphore.\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 2)\n");
}
else
{
printf("value = %d(try 2)\n", val);
}
/*************** */
if (!semPost(&hase m)) //sem_post() wrapper function
{
printf("Failed to post semaphore.\n");
}
if (!semGetValue(& hasem, &val))
{
printf("Failed to get semaphore value.(try 3)\n");
}
else
{
printf("value = %d(try 3)\n", val);
}
if (!semDestroy(&h asem))
{
printf("Failed to unlink semDestroy().\n ");
}
exit(0);
}
Without link to libdb2 the result is:
(gcc -g -O2 -D_REENTRANT -Wall -D__EXTENSIONS__ -I ~qq/rxgui/inc -c -o
hursemgetvalue. o hursemgetvalue. c
gcc -g -O2 -D_REENTRANT -Wall -D__EXTENSIONS__ -o hursemgetvalue
hursemgetvalue. o ~qq/rxgui/S*/obj/libhasem.a -lrt -lposix4 )
value = 1(try 1)
value = 0(try 2)
value = 1(try 3)
But if I link to libdb2 as well, the executable runs with incorrect
behavior. And the following is the printf output:
(gcc -g -Wall -I ~qq/rxgui/inc -c -o hursemgetvalue. o hursemgetvalue. c
gcc -o hursemgetvalue hursemgetvalue. o ~qq/rxgui/S*/obj/libhasem.a
-lrt -lposix4 -R/export/home/db2eee1a/sqllib/lib -ldb2)
value = 0(try 1)
value = 0(try 2)
value = 0(try 3)
As you can see, the semaphore value is always 0 and doesn't perform
locking function as well. I don't know if it's a DB2 bug or me making
a mistake somewhere. Any help or direction is greatly appreciated.
The DB2 SDK version is 7.2.9 on Solaris 8 and I am using gcc compiler.
First question: any chance on moving to a supported DB2 version like V8 or,
better yet, V9.
What would also be interesting to know are the definitions of your various
sem* functions. The POSIX semaphore functions are not mixed case, e.g.
sem_destroy and not semDestroy.
And finally, what's the output of the linkage editor?
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bastian Hammer |
last post by:
Hi
I´m wondering why there are so few examples with Semaphore.
Is it obsolete?
I´ve got a Class Data.
It offers 2 Threads methods for updating, editing, .. a private
dictionary.
Now I have to make sure, that both threads are synchronal,
|
by: dede |
last post by:
Dear community,
having written a working example for using Semphores on a windows
client, I created a little "server-application" that does the following:
A Server continously "listens/tails" a command-file for new commands.
If a new commands arrives a split of the workload to threads is under-
taken that "control themselves" via Semaphore and are joined finally.
It works.
|
by: rushik |
last post by:
Hello all,
I m facing an interesting problem related to semaphore in php.
We are using a huge business application running on LAMP. For database
operations we are maintaining centralized DB manager classes in php
which perform all the single table related activity. Before inserting
new record we are acquiring semaphore on specific key (all the tables
are having seprate sem keys), insert the record and release the
semaphore.
|
by: Vandana Sharma |
last post by:
Hi, I am trying to run my application (32-bit) on HP-UX 11.22i (64-bit)
and am getting the above message while dynamically loading libdb2.so
from my application. I am using dlopen as follows:
dlopen(libName, RTLD_NOW);
I have looked up notes from DB2 that say that as long as I link with
32-bit DB2 libs, the application should work. I have made sure I have
32-bit DB2 libs in the SHLIB_PATH and also made sure that my
application is...
|
by: techi_C |
last post by:
Hi
I'm getting a problem while removing semaphore from system.
Before removing semaphore I'm checking the usage count of a smaphore.
// checking usage count
usage_count = semctl(sem_ptr->semid, 1, GETVAL, NULL);
if( usage_count 1 )
// return don't remove semaphore
else
| |
by: Samuel R. Neff |
last post by:
I'm having trouble creating a Semaphore with read-access rights for
everyone. Originally I was trying to use this code:
semaphore = new Semaphore(maxLocks, maxLocks, "RwLock#" + name);
but when using that code to create a Semaphore instance for an
existing system semaphore (i.e., the second time the code gets hit), I
get an UnauthorizedAccessException. So I tried specifying that
everyone has read rights:
|
by: Justin |
last post by:
When creating an executible received this error during the linking...
g++32 -L/usr/lib/x86_64-redhat-linux3E/lib64 -o confusion cdb.o
conindb.o confusdb.o confusion.o ../../arc/lib/arc.a ../shared/lib/
database.a -Wl,-rpath,/home/userid/sqllib/lib -L/home/userid/sqllib/
lib -ldb2 -lpthread
/home/userid/sqllib/lib/libdb2.so: undefined reference to
`__cxa_guard_acquire@CXXABI_1.2.1'
/home/userid/sqllib/lib/libdb2.so: undefined reference...
|
by: Ajb181 |
last post by:
hi all. i have a template class that i can not link. there is no problem when i add the method def's inside the header file but as soon as i move them out i get a link error where i define the object. i have tryed a simple test of the same code and it links fine so am baffeled at what is happing
this is my simple test that complies and links
bool test();
template <class T>
class queue
|
by: noashira |
last post by:
Hi All,
I'll be happy to get your opinionn this, i have a webservice that uses Semaphore to access shared (VB) resources and i noticed that the semaphore could not make locks using the WaitOne() method, when using it, it throws an exception "Thread was being aborted." after 2 minutes.
I believe its aprobably a timeout error, but not sure what is the cause..
Can someone please explain what effects the lock? why t could be completed? what...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |