|
![]() ![]()
|
The locking subsystem provides interprocess and intraprocess concurrency control mechanisms. Although the lock system is used extensively by the Berkeley DB access methods and transaction system, it may also be used as a standalone subsystem to provide concurrency control to any set of designated resources.
(락 서브시스템은 프로세스와 쓰레드의 동시성을 제어하는 메카니즘을 제공한다.비록 락 시스템이 버클리디비 액세스 메소드와 트랜젝션 시스템에서 광범위하게 사용될지라도 대상리소스에 동시성 컨트롤을 제공하기 위해 스탠드얼론 서브시스템으로 사용될 수 있다.)
The Lock subsystem is created, initialized, and opened by calls to DB_ENV->open with the DB_INIT_LOCK or DB_INIT_CDB flags specified.
(락 서브시스템은 DB_ENV->open (DB_INIT_LOCK or DB_INIT_CDB flags )에 의해 생성,초기화,오픈된다.)
The DB_ENV->lock_vec method is used to acquire and release locks. The DB_ENV->lock_vec method performs any number of lock operations atomically. It also provides the capability to release all locks held by a particular locker and release all the locks on a particular object. (Performing multiple lock operations atomically is useful in performing Btree traversals -- you want to acquire a lock on a child page and once acquired, immediately release the lock on its parent. This is traditionally referred to as lock-coupling). Two additional methods, DB_ENV->lock_get and DB_ENV->lock_put, are provided. These methods are simpler front-ends to the DB_ENV->lock_vec functionality, where DB_ENV->lock_get acquires a lock, and DB_ENV->lock_put releases a lock that was acquired using DB_ENV->lock_get or DB_ENV->lock_vec. All locks explicitly requested by an application should be released via calls to DB_ENV->lock_put or DB_ENV->lock_vec. Using DB_ENV->lock_vec instead of separate calls to DB_ENV->lock_put and DB_ENV->lock_get also reduces the synchronization overhead between multiple threads or processes. The three methods are fully compatible, and may be used interchangeably.
DB_ENV->lock_vec는 락을 얻는것과 릴리즈하는데 사용된다.이 메소드는 여러 락 동작을 원자적으로 실행한다.이것은 또한 특정한 하나의 락커에 의해 잡혀진 모른 락을 릴리즈하고 특정한 오브젝트에 대한 모든 락을 릴리즈하는 기능을 제공한다.(원자적으로 여러 락 오퍼레이션을 실행하는것은 Btree순회를 실행하는데 유용하다.여러분은 자식페이지에 대한 락을 얻은후 부모에 대한 락을 즉시 릴리즈하고 싶어할것이다.이러한동작은 전통적으로 .락커플링이라 불린다.) 두개의 추가적 DB_ENV->lock_get and DB_ENV->lock_put가 제공된다. 이메소드는 DB_ENV->lock_vec기능의 프런트-앤드 심플러이다.DB_ENV->lock_get 은 락을 얻고 DB_ENV->lock_put은 DB_ENV->lock_get or DB_ENV->lock_vec에서 얻어진 락을 릴리즈한다.애플리케이션이 명시적으로 락을 요청했다면 DB_ENV->lock_put or DB_ENV->lock_vec를 사용하여 락은 릴리즈되어야 한다. 개별적인 DB_ENV->lock_put and DB_ENV->lock_get 의 호출대신 DB_ENV->lock_vec 를 호출하는 것은 동기화 오버해드를 감소시킨다.이 세개의 메소드는 완전히 호환가능하고 교차하면서 사용될 수 있다.)
Applications must specify lockers and lock objects appropriately. When used with the Berkeley DB access methods, lockers and objects are handled completely internally, but an application using the lock manager directly must either use the same conventions as the access methods or define its own convention to which it adheres. If an application is using the access methods with locking at the same time that it is calling the lock manager directly, the application must follow a convention that is compatible with the access methods' use of the locking subsystem. See Access method locking conventions for more information.
(애플리케이션은 락오브젝와 락커를 적절히 설정해야 한다.버클리디비 액세스 메소드가 사용될때 락커와 오브젝트는 내부적으로 완전히 핸들링된다.그러나 직접 락메니저를 사용하는 애플리케이션은 액세스메소드에 대한 컨벤션이나 자체 컨벤션을 정의중 하나를 사용해야 한다.만약 애플리케이션이 락메니저를 부르면서 동시에 락킹과 함께 액세스 메소드를 사용하는 애플리케이션은 액세스메소드의 락서브시스템사용 컨벤션과 호환가능해야 한다. Access method locking conventions 참조)
The DB_ENV->lock_id function returns a unique ID that may safely be used as the locker parameter to the DB_ENV->lock_vec method. The access methods use DB_ENV->lock_id to generate unique lockers for the cursors associated with a database.
(DB_ENV->lock_id 함수는 DB_ENV->lock_vec의 인자에 락커인자로 안전하게 사용될수 있는 유일한 아이디를 리턴하다.액세스메소드는 디비와 연관된 커서들에 대한 유일한 락커를 만들기 위해 DB_ENV->lock_id 를 사용한다.)
The DB_ENV->lock_detect function provides the programmatic interface to the Berkeley DB deadlock detector. Whenever two threads of control issue lock requests concurrently, the possibility for deadlock arises. A deadlock occurs when two or more threads of control are blocked, waiting for actions that another one of the blocked threads must take. For example, assume that threads A and B have each obtained read locks on object X. Now suppose that both threads want to obtain write locks on object X. Neither thread can be granted its write lock (because of the other thread's read lock). Both threads block and will never unblock because the event for which they are waiting can never happen.
(DB_ENV->lock_detect 함수는 데드락 탐지에 대한 프로그래믹 인터페이스다.두개의 쓰레드가 동시에 락을 요청했을때마다 데드락이 발생할 수 있다.데드락은 두개이상의 쓰레가 블럭된 다른 쓰레드가 행해야 하는 동작을 대기하면서 두개의 쓰레드가 블럭되어 있을때 발생한다.예를들어 쓰레드 A,B가 오브젝X에 대한 읽기락을 얻었다고 가정하고 이제 양 쓰레드가 오브젝트X에 대한 쓰기락을 얻기를 원하다고 할때 둘중 어떤 쓰레드로 쓰기락을 얻을수 없다(왜냐하며 서로다른 쓰레드가 리드락을 가지고 있기 때문이다.).양 쓰레드는 그들이 기다리고 있는 이벤트가 결코 발생하지 않기 때문에 결코 언블럭되지 않고 블락상태로 남아 있게 된다.)
The deadlock detector examines all the locks held in the environment, and identifies situations where no thread can make forward progress. It then selects one of the participants in the deadlock (according to the argument that was specified to DB_ENV->set_lk_detect), and forces it to return the value DB_LOCK_DEADLOCK, which indicates that a deadlock occurred. The thread receiving such an error must release all of its locks and undo any incomplete modifications to the locked resource. Locks are typically released, and modifications undone, by closing any cursors involved in the operation and aborting any transaction enclosing the operation. The operation may optionally be retried.
(데드락 탐지기는 환경에서 잡혀있는 모든 락을 검사한다.그리고 쓰레드가 진행될수 없는 상황을 인식하게 된다.그런후 데드락에 참여된 것들중 하나를 선택(DB_ENV->lock_detect 에 인자로 설정값에 따라)하여 강제로 데드락이 발생했음을 나타내는 DB_LOCK_DEADLOCK을 리턴시킨다.이러한 에러를 받는 쓰레드는 모든 락을 릴리즈해야 하고 락 리소스에 대한 완료되지 않은 수행을 undo해야 한다.오퍼레이션에 포함된 커서를 닫고 이 오퍼레이션을 감싸는 트랜젝션을 오버트시킴으로써 락은 특히 릴리즈되고 수정은 undo된다.그리고 이 실패된 오퍼레이션은 다시 시도해야 한다.)
The DB_ENV->lock_stat function returns information about the status of the lock subsystem. It is the programmatic interface used by the db_stat utility.
The locking subsystem is closed by the call to DB_ENV->close.
(락 서브시스템은 DB_ENV->close을 호출시 닫힌다.)
Finally, the entire locking subsystem may be discarded using the DB_ENV->remove method.
(마지막으로,전체적인 락서브시스템은 DB_ENV->remove 를 통해 버려진다.)
| Locking Subsystem and Related Methods | Description |
|---|---|
| DB_ENV->set_lk_conflicts | Set lock conflicts matrix |
| DB_ENV->set_lk_detect | Set automatic deadlock detection |
| DB_ENV->set_lk_max_lockers | Set maximum number of lockers |
| DB_ENV->set_lk_max_locks | Set maximum number of locks |
| DB_ENV->set_lk_max_objects | Set maximum number of lock objects |
| DB_ENV->set_timeout | Set lock and transaction timeout |
| DB_ENV->lock_detect | Perform deadlock detection |
| DB_ENV->lock_get | Acquire a lock |
| DB_ENV->lock_id | Acquire a locker ID |
| DB_ENV->lock_id_free | Release a locker ID |
| DB_ENV->lock_put | Release a lock |
| DB_ENV->lock_stat | Return lock subsystem statistics |
| DB_ENV->lock_vec | Acquire/release locks |
![]() ![]()
|
Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.