Using a latch between a background worker process and a thread

From: Abbas Butt <abbas(dot)butt(at)enterprisedb(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Using a latch between a background worker process and a thread
Date: 2016-11-01 16:35:51
Message-ID: CALtH27dCQgznjK9mYidK2PTgjE8KMcx_Bd0di+ggnag4N30+UQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
Consider this situation:
1. I have a background worker process.
2. The process creates a latch, initializes it using InitLatch & resets it.
3. It then creates a thread and passes the latch created in step 2 to it.
To pass it, the process uses the last argument of pthread_create.
4. The thread blocks by calling WaitLatch.
5. The process after some time sets the latch using SetLatch.

The thread does not notice that the latch has been set and keeps waiting.

My question is:
Are latches supposed to work between a process and a thread created by that
process?

Thanks.

--
--
*Abbas*
Architect

Ph: 92.334.5100153
Skype ID: gabbasb
www.enterprisedb.co <http://www.enterprisedb.com/>m
<http://www.enterprisedb.com/>

*Follow us on Twitter*
@EnterpriseDB

Visit EnterpriseDB for tutorials, webinars, whitepapers
<http://www.enterprisedb.com/resources-community> and more
<http://www.enterprisedb.com/resources-community>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2016-11-01 16:41:44 Re: Specifying the log file name of pgbench -l option
Previous Message Robert Haas 2016-11-01 16:12:32 Re: Patch: Implement failover on libpq connect level.