| Notes | 
		
		| 
 | 
	
		| 
				
					| (0000779) |  
					| wangp |  
					| 2014-09-02 16:24 |  | 
			
				| Or just condition variables, though presumably they perform worse so we would want to stick to semaphores on better platforms. |  | 
		
		| 
 | 
	
		|  | 
			
				| This would have shown up more obviously had the return value of sem_init been checked! 
 There are also a bunch of calls to various pthread_* functions in the runtime, for example pthread_mutex_init and pthread_attr_init, where the return values are not checked.
 |  | 
		
		| 
 | 
	
		| 
				
					| (0000921) |  
					| pbone |  
					| 2016-09-29 14:04 |  | 
			
				| I remember some things about writing this code but not others. 
 In particular I remember choosing semaphores for a very good reason, but I don't remember what that reason was :-(
 
 I'm not sure what should be used instead on OS X.  Except that if we want to use GCD, then we should essentially write a different implementation for the N:M threading on OS X, as GCD will (and should) handle this for us.  I suspect windows is a similar case as it supports fibers.  However that's about all I know of either platform/API.
 
 So I'd recommend trying to replace this with named semaphores, if those are supported/work, or maybe condition variables - again there's a good reason why I didn't use those but I don't know what it is.  And in the longer term consider writing an alternative implementation of all this code (maybe keep the work stealing) for OS X.
 |  | 
		
		| 
 | 
	
		|  | 
			
				| Hi Paul, 
 Using GCD to do the N:M threading is a separate issue; the semaphore implementation in libdispatch is close enough to POSIX unnamed semaphores that it should be easy enough to use as a drop-in replacement.  Using GCD in general on OS X is a much larger change.
 |  | 
		
		| 
 | 
	
		| 
				
					| (0000923) |  
					| pbone |  
					| 2016-09-29 14:24 |  | 
			
				| Agreed, which is why I said that's a longer term change, and by implication not really part of this bug.  However I wasn't aware of the primitives provided by libdispatch so I didn't know that's what you meant when you said GCD. It sounds reasonable to me. |  | 
		
		| 
 | 
	
		|  |  |