Changeset 8619f25 in mainline


Ignore:
Timestamp:
2009-08-21T07:25:50Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
207e208e
Parents:
057d21a
Message:

Fibril synchronization needs to have a means to interrupt
idle threads from waiting for IPC and get them to execute
awakened fibrils.

Location:
uspace/lib/libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/async.c

    r057d21a r8619f25  
    106106
    107107atomic_t async_futex = FUTEX_INITIALIZER;
     108
     109/** Number of threads waiting for IPC in the kernel. */
     110atomic_t threads_in_ipc_wait = { 0 };
    108111
    109112/** Structures of this type represent a waiting fibril. */
     
    683686               
    684687                futex_up(&async_futex);
     688
     689                atomic_inc(&threads_in_ipc_wait);
    685690               
    686691                ipc_call_t call;
     
    688693                    SYNCH_FLAGS_NONE);
    689694               
     695                atomic_dec(&threads_in_ipc_wait);
     696
    690697                if (!callid) {
    691698                        handle_expired_timeouts();
  • uspace/lib/libc/generic/fibril_sync.c

    r057d21a r8619f25  
    4040#include <assert.h>
    4141
     42static void optimize_execution_power(void)
     43{
     44        /*
     45         * When waking up a worker fibril previously blocked in fibril
     46         * synchronization, chances are that there is an idle manager fibril
     47         * waiting for IPC, that could start executing the awakened worker
     48         * fibril right away. We try to detect this and bring the manager
     49         * fibril back to fruitful work.
     50         */
     51        if (atomic_get(&threads_in_ipc_wait) > 0)
     52                ipc_poke();
     53}
     54
    4255void fibril_mutex_initialize(fibril_mutex_t *fm)
    4356{
     
    8497                list_remove(&f->link);
    8598                fibril_add_ready((fid_t) f);
     99                optimize_execution_power();
    86100        }
    87101}
     
    152166                        fibril_add_ready((fid_t) f);
    153167                        frw->writers++;
     168                        optimize_execution_power();
    154169                        break;
    155170                } else {
     
    157172                        fibril_add_ready((fid_t) f);
    158173                        frw->readers++;
     174                        optimize_execution_power();
    159175                }
    160176        }
     
    200216                list_remove(&f->link);
    201217                fibril_add_ready((fid_t) f);
     218                optimize_execution_power();
    202219                if (once)
    203220                        break;
  • uspace/lib/libc/include/async.h

    r057d21a r8619f25  
    4747extern atomic_t async_futex;
    4848
     49extern atomic_t threads_in_ipc_wait;
     50
    4951extern int __async_init(void);
    5052extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
Note: See TracChangeset for help on using the changeset viewer.