분류 전체보기
-
Non-blocking, Lock-free operationsStaticPL/JAVA 2020. 2. 27. 17:50
1. Overview In computer science, an algorithm is called non-blocking if failure or suspension of any thread cannot cause failure or suspension of another thread; for some operations, these algorithms provide a useful alternative to traditional blocking implementations. A non-blocking algorithm is lock-free if there is guaranteed system-wide progress, and wait-free if there is also guaranteed per..
-
SemaphoreStaticPL/JAVA 2020. 2. 27. 15:44
1. Overview Semaphore can be used to restrict the number of users to a particular resource or a group of resources, unlike the locks that allow only one user per resource. The semaphore can restrict any given number of users to a resource. 2. Description 2.1 How to use Semaphore semaphore = new Semaphore(NUMBER_OF_PERMITS); semaphore.acquire(5); // NUMBER_OF_PERMITS useResource(); semaphore.rele..
-
ReentrantReadWriteLockStaticPL/JAVA 2020. 2. 27. 11:48
1. Overview 2. ReentrantReadWriteLock 2.1 Why Multiple threads can safely read from a shared resource concurrently as long as they are not modifying its state. 2.2 Usage Synchronized and ReentrantLock do not allow multiple readers to access a shared resource concurrently. Not a big problem in the general case If we keep the critical sections short, the chances of contention over a lock are minim..
-
ReentrantLock, lockInterruptibly, and tryLockStaticPL/JAVA 2020. 2. 27. 11:02
1. Overview Reentrant Locks are provided in Java to provide synchronization with greater flexibility. 2. ReentrantLock 2.1 How to use Lock lockObject = new ReentrantLock(); public int use() throws SomException { lockObject.lock(); try{ someOperations(); return value; } finally { // Ensure releasing lock even though exception occured between locking section lockObject.unlock(); } } 2.2 Why use 2...
-
Locking Strategies and DeadlocksModeling/TheoremParadigm 2020. 2. 27. 01:37
1. Overview In concurrent computing, a deadlock is a state in which each member of a group is waiting for another member, including itself, to take action, such as sending a message or more commonly releasing a lock. Deadlock is a common problem in multiprocessing systems, parallel computing, and distributed systems, where software and hardware locks are used to arbitrate shared resources and im..
-
synchronizedStaticPL/JAVA 2020. 2. 27. 00:43
1. Overview Sometimes, you only want to prevent multiple thread access to part of the code inside a method instead of the entire method. The section of code you want to isolate this way is called a critical section and is also created using the synchronized keyword. 2. Critical section It this way, we can really achieve atomicity for any number of distinct operations without worrying about concu..
-
Resource Sharing, Critical Sections, and Atomic operationsModeling/Architecture 2020. 2. 27. 00:02
1. Overview Resource sharing is multi-thread architecture design. 2. Resource Sharing 2.1 What is a resource Variables (Integers, Strings, and etc.) Data Structures File or Connection handles Message or work queues Any Objects 2.2 Why share resources 2.2.1 Case 1 In this case, the benefit from sharing this data structure is that the document saver thread can save the user from losing his or her ..
-
Stack and Heap Memory RegionsModeling/Architecture 2020. 2. 26. 23:36
1. Overview 2. Stack 2.1 What is allocated in Stack Methods are called Arguments are passed Local variables are stored Stack + Instruction Pointer = State of each thread's execution 2.2 Example 2.3 Properties All variables belong to the thread executing on that stack Statistically allocated when the thread is created The stack's size is fixed, and relatively small which depends on the specific p..