Re: [HACKERS] Question on win32 semaphore simulation

2006-04-19 Thread Magnus Hagander
> > (2) the killer function is PGSemaphoreReset(). There is no direct > > function for this in Win32 either. > > If you can do PGSemaphoreTryLock, then Reset need only be a > loop around it (cf. posix_sema.c). In current usage Reset > doesn't have to be very efficient at all, because it's only

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > (2) the killer function is PGSemaphoreReset(). There is no direct function > for this in Win32 either. If you can do PGSemaphoreTryLock, then Reset need only be a loop around it (cf. posix_sema.c). In current usage Reset doesn't have to be very effici

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Qingqing Zhou
"Qingqing Zhou" <[EMAIL PROTECTED]> wrote > > So we might want to fix current win32/sema.c for two problems: > (1) semctl(SETVAL, val=0) - there is no other "val" than zero is used; > (2) concurrent access to sem_counts[]; > Attached is a patch for the above proposed change -- but still, I hope w

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Qingqing Zhou
""Magnus Hagander"" <[EMAIL PROTECTED]> wrote > > > > I'm not sure why the win32 port chose to emulate the SysV > > semaphore interface anyway. You could equally well have used > > the Posix interface (src/backend/port/posix_sema.c). Or, > > given Microsoft's NIH tendencies, you might have neede

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Magnus Hagander
> > Looking at the code, it looks fairly complex to me. I don't really > > know how sysv semaphores are supposed to work, or how we > use them, but > > perhaps the whole piece of code can be simplified? > > I'm not sure why the win32 port chose to emulate the SysV > semaphore interface anyway.

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Tom Lane
"Magnus Hagander" <[EMAIL PROTECTED]> writes: > Looking at the code, it looks fairly complex to me. I don't really know > how sysv semaphores are supposed to work, or how we use them, but > perhaps the whole piece of code can be simplified? I'm not sure why the win32 port chose to emulate the SysV

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-18 Thread Magnus Hagander
> > As I reviewed the win32/sema.c, there is some code that I am not > > clear, > can > > anybody explain please? > > > > There is another problem related to concurrent operations on > win32 sema. Say two processes are doing semop(+1) > concurrently. Look at this code: > > /* Don't want the

Re: [HACKERS] Question on win32 semaphore simulation

2006-04-17 Thread Qingqing Zhou
"Qingqing Zhou" <[EMAIL PROTECTED]> wrote > As I reviewed the win32/sema.c, there is some code that I am not clear, can > anybody explain please? > There is another problem related to concurrent operations on win32 sema. Say two processes are doing semop(+1) concurrently. Look at this code: /*

[HACKERS] Question on win32 semaphore simulation

2006-04-11 Thread Qingqing Zhou
As I reviewed the win32/sema.c, there is some code that I am not clear, can anybody explain please? In semctl(SETVAL): if (semun.val < sem_counts[semNum]) sops.sem_op = -1; else sops.sem_op = 1; /* Quickly lock/unlock the semaphore (if we can) */ if (semop(semId, &sops, 1) <