glossary

Difference between binary semaphore and mutex

岁酱吖の 提交于 2019-11-25 23:00:29
Is there any difference between a binary semaphore and mutex or are they essentially the same? Benoit They are NOT the same thing. They are used for different purposes! While both types of semaphores have a full/empty state and use the same API, their usage is very different. Mutual Exclusion Semaphores Mutual Exclusion semaphores are used to protect shared resources (data structure, file, etc..). A Mutex semaphore is "owned" by the task that takes it. If Task B attempts to semGive a mutex currently held by Task A, Task B's call will return an error and fail. Mutexes always use the following

What is boxing and unboxing and what are the trade offs?

与世无争的帅哥 提交于 2019-11-25 20:34:06
I'm looking for a clear, concise and accurate answer. Ideally as the actual answer, although links to good explanations welcome. Boxed values are data structures that are minimal wrappers around primitive types *. Boxed values are typically stored as pointers to objects on the heap . Thus, boxed values use more memory and take at minimum two memory lookups to access: once to get the pointer, and another to follow that pointer to the primitive. Obviously this isn't the kind of thing you want in your inner loops. On the other hand, boxed values typically play better with other types in the