![]() ![]() I am writing user code.so I get software interrupts, not hardware ones.right? I should stay away from any functions (spin/seq locks) that have the word "irq" in them. I can re-write this function to minimize lock time, but still it is so commonly called I would like to use a lock that prevents interruption.across all processors. A lot of context switching would be wasted until the thread with the lock gets rescheduled and finishes. I expect that the scheduler might schedule any number of other workers who will likely run into this function and then block because it was locked. What kinds of interruption are prevented? Can I block all threads or threads just on the locking thread's CPU? This question stems from my fear of interrupting a thread holding a lock for a very commonly used function. Which (if any) of the locks prevent interruption of a thread by the scheduler or interrupt.or am I just an idiot and all synchonization mechanisms do this. I am absolutely concerned with number of cpu cycles consumed. I don't want to consume cpu with context switching, spinning, or lots of extra cpu cycles to read and write shared memory. Performances is the utmost consideration. My questions go like this:ĭoes anyone know the cpu cycle cost of the various options? I am adding parallelism to the app so we can get better wall time response at the expense of running fewer app instances per box. You want to use a lock (mutex, futex, spin, seq, rcu) or a single atomic opertation on a lock flag when you are accessing multiple data fields. You do not want to use atomic operations on all the fields in your shared data. You have to go back and repeat the work in this case.Ītomic operations are the fastest synch call, and probably are used in all the above locking mechanisms. The seq lock just tells you when you finished your work if a writer changed the data the work was based on. They should only should be used on multi processor systems for obvious reasons. However they avoid the context switch at the expense of consuming all the cycles on a CPU until the lock is released (spinning). Spinlocks dont block and thus avoid context swtiches. Futexes might be faster than the locking mechanisms that are based on them. ![]() Semaphores are process wide, involve the filesystem (virtually I assume), and are probably the slowest.įutexes might be the base locking mechanism used by mutexes, spinlocks, seqlocks, and rculocks. My current (but probably flawed) understanding is this: I have found all of these different types of synchronizations, each with a number of functions for locking, unlocking, testing the lock, etc. ![]() I have spent some time googling to try to understand the differences between all the functions available for thread synchronization. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |