Changeset bc7d44c in mainline for uspace/lib/libc


Ignore:
Timestamp:
2009-08-21T07:33:36Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af8e565
Parents:
b9c7425 (diff), 207e208e (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 fibril synchronization improvements.

Location:
uspace/lib/libc
Files:
5 edited

Legend:

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

    rb9c7425 rbc7d44c  
    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

    rb9c7425 rbc7d44c  
    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/generic/ipc.c

    rb9c7425 rbc7d44c  
    565565}
    566566
     567/** Interrupt one thread of this task from waiting for IPC. */
     568void ipc_poke(void)
     569{
     570        __SYSCALL0(SYS_IPC_POKE);
     571}
     572
    567573/** Ask destination to do a callback connection.
    568574 *
  • uspace/lib/libc/include/async.h

    rb9c7425 rbc7d44c  
    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);
  • uspace/lib/libc/include/ipc/ipc.h

    rb9c7425 rbc7d44c  
    192192extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
    193193extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t);
     194extern void ipc_poke(void);
    194195
    195196static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
Note: See TracChangeset for help on using the changeset viewer.