Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ee42e43 in mainline


Ignore:
Timestamp:
2010-06-22T11:29:40Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
a49a1a1
Parents:
fdaad75d
Message:

Retire kernel rwlocks.

Location:
kernel
Files:
12 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    rfdaad75d ree42e43  
    241241        generic/src/synch/spinlock.c \
    242242        generic/src/synch/condvar.c \
    243         generic/src/synch/rwlock.c \
    244243        generic/src/synch/mutex.c \
    245244        generic/src/synch/semaphore.c \
     
    294293                test/mm/slab1.c \
    295294                test/mm/slab2.c \
    296                 test/synch/rwlock1.c \
    297                 test/synch/rwlock2.c \
    298                 test/synch/rwlock3.c \
    299                 test/synch/rwlock4.c \
    300                 test/synch/rwlock5.c \
    301295                test/synch/semaphore1.c \
    302296                test/synch/semaphore2.c \
  • kernel/generic/include/proc/task.h

    rfdaad75d ree42e43  
    4040#include <synch/spinlock.h>
    4141#include <synch/mutex.h>
    42 #include <synch/rwlock.h>
    4342#include <synch/futex.h>
    4443#include <adt/avl.h>
  • kernel/generic/include/proc/thread.h

    rfdaad75d ree42e43  
    4040#include <time/timeout.h>
    4141#include <cpu.h>
    42 #include <synch/rwlock.h>
    4342#include <synch/spinlock.h>
    4443#include <adt/avl.h>
     
    155154        int fpu_context_engaged;
    156155       
    157         rwlock_type_t rwlock_holder_type;
    158        
    159         /** Callback fired in scheduler before the thread is put asleep. */
    160         void (* call_me)(void *);
    161         /** Argument passed to call_me(). */
    162         void *call_me_with;
    163        
    164156        /** Thread's state. */
    165157        state_t state;
     
    239231extern void thread_detach(thread_t *);
    240232
    241 extern void thread_register_call_me(void (*)(void *), void *);
    242233extern void thread_print_list(bool);
    243234extern void thread_destroy(thread_t *, bool);
  • kernel/generic/src/proc/scheduler.c

    rfdaad75d ree42e43  
    455455                        irq_spinlock_unlock(&THREAD->sleep_queue->lock, false);
    456456                       
    457                         /*
    458                          * Check for possible requests for out-of-context
    459                          * invocation.
    460                          *
    461                          */
    462                         if (THREAD->call_me) {
    463                                 THREAD->call_me(THREAD->call_me_with);
    464                                 THREAD->call_me = NULL;
    465                                 THREAD->call_me_with = NULL;
    466                         }
    467                        
    468457                        irq_spinlock_unlock(&THREAD->lock, false);
    469                        
    470458                        break;
    471459               
  • kernel/generic/src/proc/thread.c

    rfdaad75d ree42e43  
    4848#include <synch/spinlock.h>
    4949#include <synch/waitq.h>
    50 #include <synch/rwlock.h>
    5150#include <cpu.h>
    5251#include <str.h>
     
    329328        thread->flags = flags;
    330329        thread->state = Entering;
    331         thread->call_me = NULL;
    332         thread->call_me_with = NULL;
    333330       
    334331        timeout_initialize(&thread->sleep_timeout);
     
    343340        thread->detached = false;
    344341        waitq_initialize(&thread->join_wq);
    345        
    346         thread->rwlock_holder_type = RWLOCK_NONE;
    347342       
    348343        thread->task = task;
     
    583578       
    584579        (void) waitq_sleep_timeout(&wq, usec, SYNCH_FLAGS_NON_BLOCKING);
    585 }
    586 
    587 /** Register thread out-of-context invocation
    588  *
    589  * Register a function and its argument to be executed
    590  * on next context switch to the current thread. Must
    591  * be called with interrupts disabled.
    592  *
    593  * @param call_me      Out-of-context function.
    594  * @param call_me_with Out-of-context function argument.
    595  *
    596  */
    597 void thread_register_call_me(void (* call_me)(void *), void *call_me_with)
    598 {
    599         irq_spinlock_lock(&THREAD->lock, false);
    600         THREAD->call_me = call_me;
    601         THREAD->call_me_with = call_me_with;
    602         irq_spinlock_unlock(&THREAD->lock, false);
    603580}
    604581
  • kernel/generic/src/synch/futex.c

    rfdaad75d ree42e43  
    3737
    3838#include <synch/futex.h>
    39 #include <synch/rwlock.h>
     39#include <synch/mutex.h>
    4040#include <synch/spinlock.h>
    4141#include <synch/synch.h>
     
    6565
    6666/**
    67  * Read-write lock protecting global futex hash table.
     67 * Mutex protecting global futex hash table.
    6868 * It is also used to serialize access to all futex_t structures.
    6969 * Must be acquired before the task futex B+tree lock.
    7070 */
    71 static rwlock_t futex_ht_lock;
     71static mutex_t futex_ht_lock;
    7272
    7373/** Futex hash table. */
     
    8484void futex_init(void)
    8585{
    86         rwlock_initialize(&futex_ht_lock);
     86        mutex_initialize(&futex_ht_lock, MUTEX_PASSIVE);
    8787        hash_table_create(&futex_ht, FUTEX_HT_SIZE, 1, &futex_ht_ops);
    8888}
     
    194194         * or allocate new one if it does not exist already.
    195195         */
    196         rwlock_read_lock(&futex_ht_lock);
     196        mutex_lock(&futex_ht_lock);
    197197        item = hash_table_find(&futex_ht, &paddr);
    198198        if (item) {
     
    206206                        /*
    207207                         * The futex is new to the current task.
    208                          * However, we only have read access.
    209                          * Gain write access and try again.
     208                         * Upgrade its reference count and put it to the
     209                         * current task's B+tree of known futexes.
    210210                         */
    211                         mutex_unlock(&TASK->futexes_lock);
    212                         goto gain_write_access;
     211                        futex->refcount++;
     212                        btree_insert(&TASK->futexes, paddr, futex, leaf);
    213213                }
    214214                mutex_unlock(&TASK->futexes_lock);
    215 
    216                 rwlock_read_unlock(&futex_ht_lock);
    217215        } else {
    218 gain_write_access:
     216                futex = (futex_t *) malloc(sizeof(futex_t), 0);
     217                futex_initialize(futex);
     218                futex->paddr = paddr;
     219                hash_table_insert(&futex_ht, &paddr, &futex->ht_link);
     220                       
    219221                /*
    220                  * Upgrade to writer is not currently supported,
    221                  * therefore, it is necessary to release the read lock
    222                  * and reacquire it as a writer.
     222                 * This is the first task referencing the futex.
     223                 * It can be directly inserted into its
     224                 * B+tree of known futexes.
    223225                 */
    224                 rwlock_read_unlock(&futex_ht_lock);
    225 
    226                 rwlock_write_lock(&futex_ht_lock);
    227                 /*
    228                  * Avoid possible race condition by searching
    229                  * the hash table once again with write access.
    230                  */
    231                 item = hash_table_find(&futex_ht, &paddr);
    232                 if (item) {
    233                         futex = hash_table_get_instance(item, futex_t, ht_link);
    234                        
    235                         /*
    236                          * See if this futex is known to the current task.
    237                          */
    238                         mutex_lock(&TASK->futexes_lock);
    239                         if (!btree_search(&TASK->futexes, paddr, &leaf)) {
    240                                 /*
    241                                  * The futex is new to the current task.
    242                                  * Upgrade its reference count and put it to the
    243                                  * current task's B+tree of known futexes.
    244                                  */
    245                                 futex->refcount++;
    246                                 btree_insert(&TASK->futexes, paddr, futex,
    247                                     leaf);
    248                         }
    249                         mutex_unlock(&TASK->futexes_lock);
    250        
    251                         rwlock_write_unlock(&futex_ht_lock);
    252                 } else {
    253                         futex = (futex_t *) malloc(sizeof(futex_t), 0);
    254                         futex_initialize(futex);
    255                         futex->paddr = paddr;
    256                         hash_table_insert(&futex_ht, &paddr, &futex->ht_link);
    257                        
    258                         /*
    259                          * This is the first task referencing the futex.
    260                          * It can be directly inserted into its
    261                          * B+tree of known futexes.
    262                          */
    263                         mutex_lock(&TASK->futexes_lock);
    264                         btree_insert(&TASK->futexes, paddr, futex, NULL);
    265                         mutex_unlock(&TASK->futexes_lock);
    266                        
    267                         rwlock_write_unlock(&futex_ht_lock);
    268                 }
     226                mutex_lock(&TASK->futexes_lock);
     227                btree_insert(&TASK->futexes, paddr, futex, NULL);
     228                mutex_unlock(&TASK->futexes_lock);
     229               
    269230        }
     231        mutex_unlock(&futex_ht_lock);
    270232       
    271233        return futex;
     
    318280        link_t *cur;
    319281       
    320         rwlock_write_lock(&futex_ht_lock);
     282        mutex_lock(&futex_ht_lock);
    321283        mutex_lock(&TASK->futexes_lock);
    322284
     
    338300       
    339301        mutex_unlock(&TASK->futexes_lock);
    340         rwlock_write_unlock(&futex_ht_lock);
     302        mutex_unlock(&futex_ht_lock);
    341303}
    342304
  • kernel/test/test.c

    rfdaad75d ree42e43  
    5151#include <mm/slab1.def>
    5252#include <mm/slab2.def>
    53 #include <synch/rwlock1.def>
    54 #include <synch/rwlock2.def>
    55 #include <synch/rwlock3.def>
    56 #include <synch/rwlock4.def>
    57 #include <synch/rwlock5.def>
    5853#include <synch/semaphore1.def>
    5954#include <synch/semaphore2.def>
  • kernel/test/test.h

    rfdaad75d ree42e43  
    7070extern const char *test_slab1(void);
    7171extern const char *test_slab2(void);
    72 extern const char *test_rwlock1(void);
    73 extern const char *test_rwlock2(void);
    74 extern const char *test_rwlock3(void);
    75 extern const char *test_rwlock4(void);
    76 extern const char *test_rwlock5(void);
    7772extern const char *test_semaphore1(void);
    7873extern const char *test_semaphore2(void);
Note: See TracChangeset for help on using the changeset viewer.