Changeset 12f91130 in mainline


Ignore:
Timestamp:
2007-06-28T15:49:21Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9591265
Parents:
bc1f1c2
Message:

Remove fibril_join().
We cannot guarantee our assumptions that easily.
This broken feature is removed instead of fixing because there are now users of it.

Location:
uspace/lib/libc
Files:
3 edited

Legend:

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

    rbc1f1c2 r12f91130  
    5252 *
    5353 * 1) Multithreaded client application
    54  *  create_thread(thread1);
    55  *  create_thread(thread2);
     54 *  fibril_create(fibril1);
     55 *  fibril_create(fibril2);
    5656 *  ...
    5757 * 
    58  *  thread1() {
     58 *  fibril1() {
    5959 *        conn = ipc_connect_me_to();
    6060 *        c1 = send(conn);
  • uspace/lib/libc/generic/fibril.c

    rbc1f1c2 r12f91130  
    4949#endif
    5050
     51/** This futex serializes access to ready_list, serialized_list and manage_list.
     52 */
     53static atomic_t fibril_futex = FUTEX_INITIALIZER;
     54
    5155static LIST_INITIALIZE(ready_list);
    5256static LIST_INITIALIZE(serialized_list);
     
    5559static void fibril_main(void);
    5660
    57 static atomic_t fibril_futex = FUTEX_INITIALIZER;
    58 /** Number of threads that are in async_serialized mode */
    59 static int serialized_threads;  /* Protected by async_futex */
     61/** Number of fibrils that are in async_serialized mode */
     62static int serialized_fibrils;  /* Protected by async_futex */
    6063/** Thread-local count of serialization. If >0, we must not preempt */
    6164static __thread int serialization_count;
     
    9396/** Function that spans the whole life-cycle of a fibril.
    9497 *
    95  * Each fibril begins execution in this function.  Then the function
    96  * implementing the fibril logic is called.  After its return, the return value
    97  * is saved for a potentional joiner. If the joiner exists, it is woken up. The
    98  * fibril then switches to another fibril, which cleans up after it.
     98 * Each fibril begins execution in this function. Then the function implementing
     99 * the fibril logic is called.  After its return, the return value is saved.
     100 * The fibril then switches to another fibril, which cleans up after it.
    99101 */
    100102void fibril_main(void)
     
    102104        fibril_t *f = __tcb_get()->fibril_data;
    103105
     106        /* Call the implementing function. */
    104107        f->retval = f->func(f->arg);
    105 
    106         /*
    107          * If there is a joiner, wake it up and save our return value.
    108          */
    109         if (f->joiner) {
    110                 list_append(&f->joiner->link, &ready_list);
    111                 f->joiner->joinee_retval = f->retval;
    112         }
    113108
    114109        fibril_schedule_next_adv(FIBRIL_FROM_DEAD);
     
    121116 * held.
    122117 *
    123  * @param stype         One of FIBRIL_SLEEP, FIBRIL_PREEMPT, FIBRIL_TO_MANAGER,
     118 * @param stype         Switch type. One of FIBRIL_PREEMPT, FIBRIL_TO_MANAGER,
    124119 *                      FIBRIL_FROM_MANAGER, FIBRIL_FROM_DEAD. The parameter
    125120 *                      describes the circumstances of the switch.
     
    136131        if (stype == FIBRIL_PREEMPT && list_empty(&ready_list))
    137132                goto ret_0;
    138         if (stype == FIBRIL_SLEEP) {
    139                 if (list_empty(&ready_list) && list_empty(&serialized_list))
    140                         goto ret_0;
    141         }
    142133
    143134        if (stype == FIBRIL_FROM_MANAGER) {
     
    145136                        goto ret_0;
    146137                /*
    147                  * Do not preempt if there is not sufficient count of thread
     138                 * Do not preempt if there is not sufficient count of fibril
    148139                 * managers.
    149140                 */
    150141                if (list_empty(&serialized_list) && fibrils_in_manager <=
    151                     serialized_threads) {
     142                    serialized_fibrils) {
    152143                        goto ret_0;
    153144                }
     
    191182                         * any list, we should already be somewhere, or we will
    192183                         * be lost.
    193                          *
    194                          * The stype == FIBRIL_SLEEP case is similar. The fibril
    195                          * has an external refernce which can be used to wake it
    196                          * up once that time has come.
    197184                         */
    198185                }
     
    203190                dstf = list_get_instance(manager_list.next, fibril_t, link);
    204191                if (serialization_count && stype == FIBRIL_TO_MANAGER) {
    205                         serialized_threads++;
     192                        serialized_fibrils++;
    206193                        srcf->flags |= FIBRIL_SERIALIZED;
    207194                }
     
    214201                        dstf = list_get_instance(serialized_list.next, fibril_t,
    215202                            link);
    216                         serialized_threads--;
     203                        serialized_fibrils--;
    217204                } else {
    218205                        dstf = list_get_instance(ready_list.next, fibril_t,
     
    229216        futex_up(&fibril_futex);
    230217        return retval;
    231 }
    232 
    233 /** Wait for fibril to finish.
    234  *
    235  * Each fibril can be only joined by one other fibril. Moreover, the joiner must
    236  * be from the same thread as the joinee.
    237  *
    238  * @param fid           Fibril to join.
    239  *
    240  * @return              Value returned by the completed fibril.
    241  */
    242 int fibril_join(fid_t fid)
    243 {
    244         fibril_t *f;
    245         fibril_t *cur;
    246 
    247         /* Handle fid = Kernel address -> it is wait for call */
    248         f = (fibril_t *) fid;
    249 
    250         /*
    251          * The joiner is running so the joinee isn't.
    252          */
    253         cur = __tcb_get()->fibril_data;
    254         f->joiner = cur;
    255         fibril_schedule_next_adv(FIBRIL_SLEEP);
    256 
    257         /*
    258          * The joinee fills in the return value.
    259          */
    260         return cur->joinee_retval;
    261218}
    262219
     
    286243        f->func = func;
    287244        f->clean_after_me = NULL;
    288         f->joiner = NULL;
    289         f->joinee_retval = 0;
    290245        f->retval = 0;
    291246        f->flags = 0;
  • uspace/lib/libc/include/fibril.h

    rbc1f1c2 r12f91130  
    5050
    5151typedef enum {
    52         FIBRIL_SLEEP,
    5352        FIBRIL_PREEMPT,
    5453        FIBRIL_TO_MANAGER,
     
    6867
    6968        struct fibril *clean_after_me;
    70         struct fibril *joiner;
    71         int joinee_retval;
    7269        int retval;
    7370        int flags;
     
    7976
    8077extern fid_t fibril_create(int (*func)(void *), void *arg);
    81 extern int fibril_join(fid_t fid);
    8278extern fibril_t *fibril_setup(void);
    8379extern void fibril_teardown(fibril_t *f);
Note: See TracChangeset for help on using the changeset viewer.