KNOW: Process Thread Sync Deadlock
2013-10-04 09:12
239 查看
Thread & Process
Difference Between Thread and Process
http://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-threadA process is an instance of a program in execution. A process is an independent entity to which system resources (e.g., CPU time and memory) are allocated.
A thread exists within a process and shares the process' resources. Multiple threads within the same process will share the same heap space.
Both processes and threads are independent sequences of execution. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces.
Lock & Sync
Lock
In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are manythreads of execution. A lock is designed to enforce a mutual exclusionconcurrency control policy.
Race condition
When several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, it's called race condition.Critical Section
Each process has a segment of code, called critical section, in which the process may be changing common variables, updating a table, writing a file, and so on.The code between lock and unlock calls to a mutex.
Spinlock
Spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available. Since the thread remains active but is not performing auseful task, the use of such a lock is a kind of busy waiting. Once acquired, spinlocks will usually be held until they are explicitly released.
Spinlock vs. Mutex
http://stackoverflow.com/questions/5869825/when-should-one-use-a-spinlock-instead-of-mutexSemaphore
A semaphore S is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: wait() and signal().counting semaphore: range over an unrestricted domain
binary semaphore: range only between 0 and 1
On some systems, binary semaphore are known as mutex locks, as they are locks that provide mutual exclusion.
Busy Waiting
In software engineering, busy-waiting or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available.Deadlock
Two (or more) threads have stopped execution or are spinning permanently. For example, a simple deadlock situation: thread 1 locks lock A, thread 2 locks lock B, thread 1 wants lock B and thread 2 wants lock A.Deadlock Requirement
1. Mutual exclusion. At least one resource must be held in a nonsharable mode; that is, only one process at a time can use the resource.2. Hold and wait. A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
3. No preemption. Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it, after that process has completed task.
4. Circular wait. A set{P0, P1...Pn} of waiting processes must exist such that P0 is waiting for resource hold by P1, P1 is waiting for...
Dining Philosopher
http://blog.csdn.net/b_end_an/article/details/11910651相关文章推荐
- CSharp - Working principles about Thread, Process, Multithreading, DeadLock, Lock
- Process VS Thread
- 进程(Process)和线程(Thread)的关系和区别
- 进程(process)和线程(thread)及其在项目中的应用 协程
- 进程(Process)和线程(Thread)的关系和区别(Difference)
- Exception in thread "main" java.io.IOException: Cannot run program "XX": CreateProcess error
- 计算机必知必会:进程process与线程thread
- Android中的进程(Process)和线程(Thread)
- Know about RAC Clusterware Process OPROCD
- Analysis of Process Multi-Thread Manangement Based on a simpilified Linux Kernel--myKernel
- What's the difference between a thread and a process?
- 学习笔记之深入浅出MFC 第7章 进程与线程(Process and Thread)
- Process and Thread引发的几个问题
- Python笔记-进程Process、线程Thread、上锁
- 进程(process) or 线程(thread)
- process VS thread API
- Linux process vs thread
- Storm中的process,thread,task和spout对象实例,bolt对象实例
- Activity, Service,Task, Process and Thread之间的关系
- 进程process与线程thread总结