Changes in / [5174c62:b9eb93f] in mainline


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/ipc.h

    r5174c62 rb9eb93f  
    4343#define IPC_CALL_LEN  6
    4444
    45 /** Maximum active async calls per phone */
    46 #define IPC_MAX_ASYNC_CALLS  4
     45/** Maximum active async calls per thread */
     46#ifdef CONFIG_DEBUG
     47        #define IPC_MAX_ASYNC_CALLS  16
     48#else
     49        #define IPC_MAX_ASYNC_CALLS  4000
     50#endif
    4751
    4852/* Flags for calls */
  • kernel/generic/include/proc/task.h

    r5174c62 rb9eb93f  
    9393        phone_t phones[IPC_MAX_PHONES];
    9494        stats_ipc_t ipc_info;   /**< IPC statistics */
     95        /**
     96         * Active asynchronous messages. It is used for limiting uspace to
     97         * certain extent.
     98         */
     99        atomic_t active_calls;
    95100        /** List of synchronous answerboxes. */
    96101        link_t sync_box_head;
  • kernel/generic/src/ipc/ipc.c

    r5174c62 rb9eb93f  
    655655                    (call->flags & IPC_CALL_NOTIF));
    656656               
     657                /*
     658                 * Record the receipt of this call in the current task's counter
     659                 * of active calls. IPC_M_PHONE_HUNGUP calls do not contribute
     660                 * to this counter so do not record answers to them either.
     661                 */
     662                if (!(call->flags & IPC_CALL_DISCARD_ANSWER))
     663                        atomic_dec(&TASK->active_calls);
     664               
    657665                ipc_call_free(call);
    658666        }
  • kernel/generic/src/ipc/sysipc.c

    r5174c62 rb9eb93f  
    644644}
    645645
    646 /** Check that the task did not exceed the allowed limit of asynchronous calls
    647  * made over a phone.
    648  *
    649  * @param phone Phone to check the limit against.
     646/** Check that the task did not exceed the allowed limit of asynchronous calls.
     647 *
    650648 * @return 0 if limit not reached or -1 if limit exceeded.
    651649 *
    652650 */
    653 static int check_call_limit(phone_t *phone)
    654 {
    655         if (atomic_get(&phone->active_calls) >= IPC_MAX_ASYNC_CALLS)
     651static int check_call_limit(void)
     652{
     653        if (atomic_preinc(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) {
     654                atomic_dec(&TASK->active_calls);
    656655                return -1;
     656        }
    657657       
    658658        return 0;
     
    680680    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)
    681681{
     682        if (check_call_limit())
     683                return IPC_CALLRET_TEMPORARY;
     684       
    682685        phone_t *phone;
    683686        if (phone_get(phoneid, &phone) != EOK)
    684687                return IPC_CALLRET_FATAL;
    685 
    686         if (check_call_limit(phone))
    687                 return IPC_CALLRET_TEMPORARY;
    688688       
    689689        call_t *call = ipc_call_alloc(0);
     
    720720unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data)
    721721{
     722        if (check_call_limit())
     723                return IPC_CALLRET_TEMPORARY;
     724       
    722725        phone_t *phone;
    723726        if (phone_get(phoneid, &phone) != EOK)
    724727                return IPC_CALLRET_FATAL;
    725 
    726         if (check_call_limit(phone))
    727                 return IPC_CALLRET_TEMPORARY;
    728728
    729729        call_t *call = ipc_call_alloc(0);
     
    10461046                        ipc_call_free(call);
    10471047                        goto restart;
     1048                } else {
     1049                        /*
     1050                         * Decrement the counter of active calls only if the
     1051                         * call is not an answer to IPC_M_PHONE_HUNGUP,
     1052                         * which doesn't contribute to the counter.
     1053                         */
     1054                        atomic_dec(&TASK->active_calls);
    10481055                }
    10491056               
  • kernel/generic/src/proc/task.c

    r5174c62 rb9eb93f  
    151151        atomic_set(&task->refcount, 0);
    152152        atomic_set(&task->lifecount, 0);
     153        atomic_set(&task->active_calls, 0);
    153154       
    154155        irq_spinlock_initialize(&task->lock, "task_t_lock");
     
    477478#ifdef __32_BITS__
    478479        if (*additional)
    479                 printf("%-8" PRIu64 " %9" PRIua, task->taskid,
    480                     atomic_get(&task->refcount));
     480                printf("%-8" PRIu64 " %9" PRIua " %7" PRIua, task->taskid,
     481                    atomic_get(&task->refcount), atomic_get(&task->active_calls));
    481482        else
    482483                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %10p %10p"
     
    489490        if (*additional)
    490491                printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c "
    491                     "%9" PRIua, task->taskid, ucycles, usuffix, kcycles,
    492                     ksuffix, atomic_get(&task->refcount));
     492                    "%9" PRIua " %7" PRIua,
     493                    task->taskid, ucycles, usuffix, kcycles, ksuffix,
     494                    atomic_get(&task->refcount), atomic_get(&task->active_calls));
    493495        else
    494496                printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %18p %18p\n",
  • uspace/srv/devman/devman.c

    r5174c62 rb9eb93f  
    686686}
    687687
     688static FIBRIL_MUTEX_INITIALIZE(add_device_guard);
     689
    688690/** Pass a device to running driver.
    689691 *
     
    693695void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree)
    694696{
     697        fibril_mutex_lock(&add_device_guard);
     698
    695699        /*
    696700         * We do not expect to have driver's mutex locked as we do not
     
    723727        /* Wait for answer from the driver. */
    724728        async_wait_for(req, &rc);
     729
     730        fibril_mutex_unlock(&add_device_guard);
    725731
    726732        switch(rc) {
Note: See TracChangeset for help on using the changeset viewer.