Somnath kotur wrote:
Hi All,
        I am unable to find the equivalent of the atomic_read() call in linux, 
most nic driver implementations that i am seeing in opensolaris seem to declare 
a uint32_t and then do atomic_add_32 and atomic_sub() seems to be implemented 
as atomic_add_32( b ,-a) , while the add/sub operations might work fine , im 
not sure if my atomic_read() which im just reading as is #define atomic_read(a) 
(*(a) )  would suffice?


If you're trying to ensure that the reads are not broken up by the CPU, probably.

However, IMO, atomic math operations are widely misapplied, when either locks or simple numeric values will do. Unless you know you need these (and locks won't do), I'd avoid atomic arithmetic. Using a mutex should not be substantially more expensive than atomic integers, and its easier to show correctness. (Assuming the mutex is uncontended.)

- Garrett

Thanks
Som


_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to