Changeset b50b5af2 in mainline for uspace/lib


Ignore:
Timestamp:
2009-08-22T10:48:00Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04803bf
Parents:
1ea99cc (diff), a71c158 (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 mainline changes.

Location:
uspace/lib/libc
Files:
1 added
9 edited

Legend:

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

    r1ea99cc rb50b5af2  
    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

    r1ea99cc rb50b5af2  
    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/io/printf_core.c

    r1ea99cc rb50b5af2  
    490490                counter += retval;
    491491       
    492         /* Print tailing spaces */
     492        /* Print trailing spaces */
    493493       
    494494        while (width-- > 0) {
  • uspace/lib/libc/generic/io/vsnprintf.c

    r1ea99cc rb50b5af2  
    100100        }
    101101       
    102         /* Buffer is big enought to print the whole string */
     102        /* Buffer is big enough to print the whole string */
    103103        memcpy((void *)(data->dst + data->len), (void *) str, size);
    104104        data->len += size;
  • uspace/lib/libc/generic/ipc.c

    r1ea99cc rb50b5af2  
    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/generic/malloc.c

    r1ea99cc rb50b5af2  
    392392                if (orig_size - real_size >= STRUCT_OVERHEAD) {
    393393                        /* Split the original block to a full block
    394                            and a tailing free block */
     394                           and a trailing free block */
    395395                        block_init((void *) head, real_size, false);
    396396                        block_init((void *) head + real_size,
  • uspace/lib/libc/generic/vfs/vfs.c

    r1ea99cc rb50b5af2  
    122122        int res;
    123123        ipcarg_t rc;
     124        ipcarg_t rc_orig;
    124125        aid_t req;
    125126        dev_handle_t dev_handle;
     
    141142        rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_size);
    142143        if (rc != EOK) {
    143                 async_wait_for(req, NULL);
     144                async_wait_for(req, &rc_orig);
    144145                async_serialize_end();
    145146                futex_up(&vfs_phone_futex);
    146147                free(mpa);
    147                 return (int) rc;
     148                if (rc_orig == EOK)
     149                        return (int) rc;
     150                else
     151                        return (int) rc_orig;
    148152        }
    149153       
    150154        rc = ipc_data_write_start(vfs_phone, (void *) opts, str_size(opts));
    151155        if (rc != EOK) {
    152                 async_wait_for(req, NULL);
     156                async_wait_for(req, &rc_orig);
    153157                async_serialize_end();
    154158                futex_up(&vfs_phone_futex);
    155159                free(mpa);
    156                 return (int) rc;
     160                if (rc_orig == EOK)
     161                        return (int) rc;
     162                else
     163                        return (int) rc_orig;
    157164        }
    158165
    159166        rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
    160167        if (rc != EOK) {
    161                 async_wait_for(req, NULL);
     168                async_wait_for(req, &rc_orig);
    162169                async_serialize_end();
    163170                futex_up(&vfs_phone_futex);
    164171                free(mpa);
    165                 return (int) rc;
     172                if (rc_orig == EOK)
     173                        return (int) rc;
     174                else
     175                        return (int) rc_orig;
    166176        }
    167177
     
    169179        rc = async_req_0_0(vfs_phone, IPC_M_PING);
    170180        if (rc != EOK) {
    171                 async_wait_for(req, NULL);
     181                async_wait_for(req, &rc_orig);
    172182                async_serialize_end();
    173183                futex_up(&vfs_phone_futex);
    174184                free(mpa);
    175                 return (int) rc;
     185                if (rc_orig == EOK)
     186                        return (int) rc;
     187                else
     188                        return (int) rc_orig;
    176189        }
    177190       
     
    202215        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    203216        if (rc != EOK) {
    204                 async_wait_for(req, NULL);
     217                ipcarg_t rc_orig;
     218       
     219                async_wait_for(req, &rc_orig);
    205220                async_serialize_end();
    206221                futex_up(&vfs_phone_futex);
    207222                free(pa);
    208                 return (int) rc;
     223                if (rc_orig == EOK)
     224                        return (int) rc;
     225                else
     226                        return (int) rc_orig;
    209227        }
    210228        async_wait_for(req, &rc);
     
    240258       
    241259        if (rc != EOK)
    242             return (int) rc;
     260                return (int) rc;
    243261       
    244262        return (int) IPC_GET_ARG1(answer);
     
    274292        rc = ipc_data_read_start(vfs_phone, (void *)buf, nbyte);
    275293        if (rc != EOK) {
    276                 async_wait_for(req, NULL);
    277                 async_serialize_end();
    278                 futex_up(&vfs_phone_futex);
    279                 return (ssize_t) rc;
     294                ipcarg_t rc_orig;
     295       
     296                async_wait_for(req, &rc_orig);
     297                async_serialize_end();
     298                futex_up(&vfs_phone_futex);
     299                if (rc_orig == EOK)
     300                        return (ssize_t) rc;
     301                else
     302                        return (ssize_t) rc_orig;
    280303        }
    281304        async_wait_for(req, &rc);
     
    301324        rc = ipc_data_write_start(vfs_phone, (void *)buf, nbyte);
    302325        if (rc != EOK) {
    303                 async_wait_for(req, NULL);
    304                 async_serialize_end();
    305                 futex_up(&vfs_phone_futex);
    306                 return (ssize_t) rc;
     326                ipcarg_t rc_orig;
     327       
     328                async_wait_for(req, &rc_orig);
     329                async_serialize_end();
     330                futex_up(&vfs_phone_futex);
     331                if (rc_orig == EOK)
     332                        return (ssize_t) rc;
     333                else
     334                        return (ssize_t) rc_orig;
    307335        }
    308336        async_wait_for(req, &rc);
     
    376404        rc = ipc_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat));
    377405        if (rc != EOK) {
    378                 async_wait_for(req, NULL);
    379                 async_serialize_end();
    380                 futex_up(&vfs_phone_futex);
    381                 return (ssize_t) rc;
     406                ipcarg_t rc_orig;
     407               
     408                async_wait_for(req, &rc_orig);
     409                async_serialize_end();
     410                futex_up(&vfs_phone_futex);
     411                if (rc_orig == EOK)
     412                        return (ssize_t) rc;
     413                else
     414                        return (ssize_t) rc_orig;
    382415        }
    383416        async_wait_for(req, &rc);
     
    391424{
    392425        ipcarg_t rc;
     426        ipcarg_t rc_orig;
    393427        aid_t req;
    394428       
     
    405439        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    406440        if (rc != EOK) {
    407                 async_wait_for(req, NULL);
     441                async_wait_for(req, &rc_orig);
    408442                async_serialize_end();
    409443                futex_up(&vfs_phone_futex);
    410444                free(pa);
    411                 return (int) rc;
     445                if (rc_orig == EOK)
     446                        return (int) rc;
     447                else
     448                        return (int) rc_orig;
    412449        }
    413450        rc = ipc_data_read_start(vfs_phone, stat, sizeof(struct stat));
    414451        if (rc != EOK) {
    415                 async_wait_for(req, NULL);
     452                async_wait_for(req, &rc_orig);
    416453                async_serialize_end();
    417454                futex_up(&vfs_phone_futex);
    418455                free(pa);
    419                 return (int) rc;
     456                if (rc_orig == EOK)
     457                        return (int) rc;
     458                else
     459                        return (int) rc_orig;
    420460        }
    421461        async_wait_for(req, &rc);
     
    476516        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    477517        if (rc != EOK) {
    478                 async_wait_for(req, NULL);
     518                ipcarg_t rc_orig;
     519       
     520                async_wait_for(req, &rc_orig);
    479521                async_serialize_end();
    480522                futex_up(&vfs_phone_futex);
    481523                free(pa);
    482                 return (int) rc;
     524                if (rc_orig == EOK)
     525                        return (int) rc;
     526                else
     527                        return (int) rc_orig;
    483528        }
    484529        async_wait_for(req, &rc);
     
    506551        rc = ipc_data_write_start(vfs_phone, pa, pa_size);
    507552        if (rc != EOK) {
    508                 async_wait_for(req, NULL);
     553                ipcarg_t rc_orig;
     554
     555                async_wait_for(req, &rc_orig);
    509556                async_serialize_end();
    510557                futex_up(&vfs_phone_futex);
    511558                free(pa);
    512                 return (int) rc;
     559                if (rc_orig == EOK)
     560                        return (int) rc;
     561                else
     562                        return (int) rc_orig;
    513563        }
    514564        async_wait_for(req, &rc);
     
    532582{
    533583        ipcarg_t rc;
     584        ipcarg_t rc_orig;
    534585        aid_t req;
    535586       
     
    553604        rc = ipc_data_write_start(vfs_phone, olda, olda_size);
    554605        if (rc != EOK) {
    555                 async_wait_for(req, NULL);
     606                async_wait_for(req, &rc_orig);
    556607                async_serialize_end();
    557608                futex_up(&vfs_phone_futex);
    558609                free(olda);
    559610                free(newa);
    560                 return (int) rc;
     611                if (rc_orig == EOK)
     612                        return (int) rc;
     613                else
     614                        return (int) rc_orig;
    561615        }
    562616        rc = ipc_data_write_start(vfs_phone, newa, newa_size);
    563617        if (rc != EOK) {
    564                 async_wait_for(req, NULL);
     618                async_wait_for(req, &rc_orig);
    565619                async_serialize_end();
    566620                futex_up(&vfs_phone_futex);
    567621                free(olda);
    568622                free(newa);
    569                 return (int) rc;
     623                if (rc_orig == EOK)
     624                        return (int) rc;
     625                else
     626                        return (int) rc_orig;
    570627        }
    571628        async_wait_for(req, &rc);
  • uspace/lib/libc/include/async.h

    r1ea99cc rb50b5af2  
    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

    r1ea99cc rb50b5af2  
    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.