vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > > 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 lock anymore */ > sem_counts[sops[0].sem_num]++; > ReleaseSemaphore(cur_handle, sops[0].sem_op, NULL); > > Except for the problem mentioned in the above thread that the > first line should be: sem_counts[sops[0].sem_num] += > sops[0].sem_op, the sem_counts[] are unprotected by anything, > so we might lose an update. Maybe I totally misunderstand something? I've never really looked intot eh semaphore stuff, but if sem_counts[] is in shared memory it should definitly be protected. 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? //Magnus ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |
| ||||
| "Magnus Hagander" <mha@sollentuna.net> 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 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 needed to write a third implementation of the pg_sema.h interface ... but it'd likely still be no larger than win32/sema.c ... regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |