From 6e72f897f4d3adb220c53482aa6133f13e0df4b1 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 10 Jun 2011 17:12:51 +0000 Subject: [PATCH] Remove the global lock and the documentation for it. It was specific to the tty driver and doesn't apply to the generic module. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42086 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/generic/tty/module.cpp | 1 + src/add-ons/kernel/generic/tty/tty.cpp | 22 ++++---------------- src/add-ons/kernel/generic/tty/tty_private.h | 1 - 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/add-ons/kernel/generic/tty/module.cpp b/src/add-ons/kernel/generic/tty/module.cpp index a5d6296573..2eda28d6a0 100644 --- a/src/add-ons/kernel/generic/tty/module.cpp +++ b/src/add-ons/kernel/generic/tty/module.cpp @@ -68,6 +68,7 @@ static struct tty_module_info sTTYModule = { 0, //B_KEEP_LOADED, tty_module_std_ops }, + &tty_create, &tty_destroy, &tty_create_cookie, diff --git a/src/add-ons/kernel/generic/tty/tty.cpp b/src/add-ons/kernel/generic/tty/tty.cpp index 544f36a9dc..2f1f11c73a 100644 --- a/src/add-ons/kernel/generic/tty/tty.cpp +++ b/src/add-ons/kernel/generic/tty/tty.cpp @@ -41,14 +41,9 @@ Locking ------- - There are four locks involved. If more than one needs to be held at a + There are three locks involved. If more than one needs to be held at a time, they must be acquired in the order they are listed here. - gGlobalTTYLock: Guards open/close operations. When held, tty_open(), - tty_close(), tty_close_cookie() etc. won't be invoked by other threads, - cookies won't be added to/removed from TTYs, and tty::ref_count, - tty::open_count, tty_cookie::closed won't change. - gTTYCookieLock: Guards the access to the fields tty_cookie::{thread_count,closed}, or more precisely makes access to them atomic. thread_count is the number of threads currently using the cookie @@ -59,9 +54,8 @@ tty::lock: Guards the access to tty::{input_buffer,settings::{termios, window_size,pgrp_id}}. Moreover when held guarantees that tty::open_count - won't drop to zero (both gGlobalTTYLock and tty::lock must be held to - decrement it). A tty and the tty connected to it (master and slave) share - the same lock. + won't drop to zero. A tty and the tty connected to it (master and slave) + share the same lock. gTTYRequestLock: Guards access to tty::{reader,writer}_queue (most RequestQueue methods do the locking themselves (the lock is a @@ -863,8 +857,6 @@ tty_input_putc(struct tty* tty, int c) #endif // 0 -/*! The global lock must be held. -*/ tty_cookie* tty_create_cookie(struct tty* tty, struct tty* otherTTY, uint32 openMode) { @@ -896,8 +888,6 @@ tty_create_cookie(struct tty* tty, struct tty* otherTTY, uint32 openMode) } -/*! The global lock must be held. -*/ void tty_destroy_cookie(tty_cookie* cookie) { @@ -917,8 +907,6 @@ tty_destroy_cookie(tty_cookie* cookie) } -/*! The global lock must be held. -*/ void tty_close_cookie(tty_cookie* cookie) { @@ -958,9 +946,7 @@ tty_close_cookie(tty_cookie* cookie) // For the removal of the cookie acquire the TTY's lock. This ensures, that // cookies will not be removed from a TTY (or added -- cf. add_tty_cookie()) - // as long as the TTY's lock is being held. This is required for the select - // support, since we need to iterate through the cookies of a TTY without - // having to acquire the global lock. + // as long as the TTY's lock is being held. MutexLocker ttyLocker(cookie->tty->lock); // remove the cookie from the TTY's cookie list diff --git a/src/add-ons/kernel/generic/tty/tty_private.h b/src/add-ons/kernel/generic/tty/tty_private.h index 4f269d057b..97bbe68036 100644 --- a/src/add-ons/kernel/generic/tty/tty_private.h +++ b/src/add-ons/kernel/generic/tty/tty_private.h @@ -142,7 +142,6 @@ struct tty { }; -extern struct mutex gGlobalTTYLock; extern struct mutex gTTYCookieLock; extern struct recursive_lock gTTYRequestLock;