Changeset 235d31d in mainline for uspace/lib/c/generic/fibril.c


Ignore:
Timestamp:
2014-12-22T17:47:40Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8c7d5ad
Parents:
eae91e0 (diff), 759ea0d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge the CHT pre-integration branch

This branch contains:

  • the merge of lp:~adam-hraska+lp/helenos/rcu, which brings:
  • a new preemptible kernel RCU variant called A-RCU,
  • a preemptible variant of Podzimek's non-preemptible kernel RCU and
  • a new variant of usersace RCU,
  • a new concurrent hash table (CHT) implementation based on RCU,
  • a deployment of CHT in kernel futex handling,
  • a deployment of the userspace RCU in the implementation of upgradable futexes,

all described in Adam Hraska's master thesis named Read-Copy-Update
for HelenOS, defended in 2013 at MFF UK; furthemore, the branch
fixes two synchronization bugs in condvars and waitq, respectively:

  • revid:adam.hraska+hos@gmail.com-20121116144921-3to9u1tn1sg07rg7
  • revid:adam.hraska+hos@gmail.com-20121116173623-km7gwtqixwudpe66
  • build fixes required to pass make check
  • overhaul of ia64 and sparc64 trap handling, to allow exc_dispatch() to be used now when the kernel is more picky about CPU state accounting
  • an important fix of the sparc64/sun4v preemptible trap handler
  • various other fixes of issues discovered on non-x86 architectures
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/fibril.c

    reae91e0 r235d31d  
    4949#include <assert.h>
    5050#include <async.h>
     51#include <futex.h>
     52
     53#ifdef FUTEX_UPGRADABLE
     54#include <rcu.h>
     55#endif
    5156
    5257/**
     
    5459 * serialized_list and manager_list.
    5560 */
    56 static atomic_t fibril_futex = FUTEX_INITIALIZER;
     61static futex_t fibril_futex = FUTEX_INITIALIZER;
    5762
    5863static LIST_INITIALIZE(ready_list);
     
    8388{
    8489        fibril_t *fibril = __tcb_get()->fibril_data;
     90
     91#ifdef FUTEX_UPGRADABLE
     92        rcu_register_fibril();
     93#endif
    8594       
    8695        /* Call the implementing function. */
     
    146155        int retval = 0;
    147156       
    148         futex_down(&fibril_futex);
     157        futex_lock(&fibril_futex);
    149158       
    150159        if (stype == FIBRIL_PREEMPT && list_empty(&ready_list))
     
    168177        if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
    169178                while (list_empty(&manager_list)) {
    170                         futex_up(&fibril_futex);
     179                        futex_unlock(&fibril_futex);
    171180                        async_create_manager();
    172                         futex_down(&fibril_futex);
     181                        futex_lock(&fibril_futex);
    173182                }
    174183        }
     
    203212                        }
    204213                       
    205                         return 1;       /* futex_up already done here */
     214                        return 1;       /* futex_unlock already done here */
    206215                }
    207216               
     
    246255        list_remove(&dstf->link);
    247256       
    248         futex_up(&fibril_futex);
     257        futex_unlock(&fibril_futex);
     258       
     259#ifdef FUTEX_UPGRADABLE
     260        if (stype == FIBRIL_FROM_DEAD) {
     261                rcu_deregister_fibril();
     262        }
     263#endif
     264       
    249265        context_restore(&dstf->ctx);
    250266        /* not reached */
    251267       
    252268ret_0:
    253         futex_up(&fibril_futex);
     269        futex_unlock(&fibril_futex);
    254270        return retval;
    255271}
     
    318334        fibril_t *fibril = (fibril_t *) fid;
    319335       
    320         futex_down(&fibril_futex);
     336        futex_lock(&fibril_futex);
    321337       
    322338        if ((fibril->flags & FIBRIL_SERIALIZED))
     
    325341                list_append(&fibril->link, &ready_list);
    326342       
    327         futex_up(&fibril_futex);
     343        futex_unlock(&fibril_futex);
    328344}
    329345
     
    338354        fibril_t *fibril = (fibril_t *) fid;
    339355       
    340         futex_down(&fibril_futex);
     356        futex_lock(&fibril_futex);
    341357        list_append(&fibril->link, &manager_list);
    342         futex_up(&fibril_futex);
     358        futex_unlock(&fibril_futex);
    343359}
    344360
     
    346362void fibril_remove_manager(void)
    347363{
    348         futex_down(&fibril_futex);
     364        futex_lock(&fibril_futex);
    349365       
    350366        if (!list_empty(&manager_list))
    351367                list_remove(list_first(&manager_list));
    352368       
    353         futex_up(&fibril_futex);
     369        futex_unlock(&fibril_futex);
    354370}
    355371
Note: See TracChangeset for help on using the changeset viewer.