Using Locks in a function

hai plz help me

Iam locking an object in a function fun1()
and iam using that object in another function fun2() and unlockin it
will the lock still holds good in fun2()
the object is globally declared

consider the following scenario

object obj;
void fun2()
{
fun1();
obj.display();
unlock();
}

obj& fun1()
{
lock();
return obj;
}

The object that iam trying to lock is an array of 3 objects. i want to have access of the object which is not locked from the 3 objects.
these objects are used for establishing a session to the server.
Whenever a new process tries to get access to the server, it should check the available session object, lock it, and unlock after using it
The array of objects are in the shared memory, and the object that is encapsulating the array of objects is a singleton object

Hope this gives you a clear picture to solve my problem

plz help me its urgent

Thanks
Vadan
Reported. Duplicate Topic.

Please keep topics in a single forum.
Topic archived. No new replies allowed.