Changeset bc1f1c2 in mainline


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

Goodbye pseudo threads, welcome fibrils.
The renaming might still be incomplete.

Files:
2 added
2 deleted
24 edited
17 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/context.s

    rb9641ee rbc1f1c2  
    4040context_save_arch:
    4141        movl 0(%esp),%eax       # the caller's return %eip
    42         movl 4(%esp),%edx       # address of the kernel_context variable to save context to
     42        movl 4(%esp),%edx       # address of the context variable to save context to
    4343
    4444        movl %esp,0(%edx)       # %esp -> ctx->sp
     
    6060#
    6161context_restore_arch:
    62         movl 4(%esp),%eax       # address of the kernel_context variable to restore context from
     62        movl 4(%esp),%eax       # address of the context variable to restore context from
    6363        movl 0(%eax),%esp       # ctx->sp -> %esp
    6464        movl 4(%eax),%edx       # ctx->pc -> %edx
  • uspace/lib/libc/Makefile

    rb9641ee rbc1f1c2  
    6464        generic/io/printf_core.c \
    6565        malloc/malloc.c \
    66         generic/psthread.c \
     66        generic/fibril.c \
    6767        generic/sysinfo.c \
    6868        generic/ipc.c \
  • uspace/lib/libc/arch/amd64/Makefile.inc

    rb9641ee rbc1f1c2  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
    36                 arch/$(ARCH)/src/psthread.S \
     36                arch/$(ARCH)/src/fibril.S \
    3737                arch/$(ARCH)/src/thread.c
    3838
  • uspace/lib/libc/arch/amd64/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_amd64_PSTHREAD_H_
    36 #define LIBC_amd64_PSTHREAD_H_
     35#ifndef LIBC_amd64_FIBRIL_H_
     36#define LIBC_amd64_FIBRIL_H_
    3737
    3838#include <types.h>
  • uspace/lib/libc/arch/amd64/include/thread.h

    rb9641ee rbc1f1c2  
    4040typedef struct {
    4141        void *self;
    42         void *pst_data;
     42        void *fibril_data;
    4343} tcb_t;
    4444
  • uspace/lib/libc/arch/arm32/Makefile.inc

    rb9641ee rbc1f1c2  
    3737
    3838ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    39                 arch/$(ARCH)/src/psthread.S \
     39                arch/$(ARCH)/src/fibril.S \
    4040                arch/$(ARCH)/src/thread.c \
    4141                arch/$(ARCH)/src/eabi.S
  • uspace/lib/libc/arch/arm32/include/fibril.h

    rb9641ee rbc1f1c2  
    3131 */
    3232/** @file
    33  *  @brief psthread related declarations.
     33 *  @brief Fibrils related declarations.
    3434 */
    3535
    36 #ifndef LIBC_arm32_PSTHREAD_H_
    37 #define LIBC_arm32_PSTHREAD_H_
     36#ifndef LIBC_arm32_FIBRIL_H_
     37#define LIBC_arm32_FIBRIL_H_
    3838
    3939#include <types.h>
     
    6464
    6565
    66 /** Thread context.
     66/** Fibril context.
    6767 *
    6868 *  Only registers preserved accross function calls are included. r9 is used
  • uspace/lib/libc/arch/arm32/include/thread.h

    rb9641ee rbc1f1c2  
    5050 */
    5151typedef struct {
    52         /** psthread data. */
    53         void *pst_data;
     52        /** Fibril data. */
     53        void *fibril_data;
    5454} tcb_t;
    5555
  • uspace/lib/libc/arch/ia32/Makefile.inc

    rb9641ee rbc1f1c2  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    36                 arch/$(ARCH)/src/psthread.S \
     36                arch/$(ARCH)/src/fibril.S \
    3737                arch/$(ARCH)/src/thread.c
    3838
  • uspace/lib/libc/arch/ia32/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_ia32_PSTHREAD_H_
    36 #define LIBC_ia32_PSTHREAD_H_
     35#ifndef LIBC_ia32_FIBRIL_H_
     36#define LIBC_ia32_FIBRIL_H_
    3737
    3838#include <types.h>
  • uspace/lib/libc/arch/ia32/include/thread.h

    rb9641ee rbc1f1c2  
    4040typedef struct {
    4141        void *self;
    42         void *pst_data;
     42        void *fibril_data;
    4343} tcb_t;
    4444
     
    5050static inline tcb_t * __tcb_get(void)
    5151{
    52         void * retval;
     52        void *retval;
    5353
    5454        asm ("movl %%gs:0, %0" : "=r"(retval));
  • uspace/lib/libc/arch/ia32/src/fibril.S

    rb9641ee rbc1f1c2  
    4040context_save:
    4141        movl 0(%esp),%eax       # the caller's return %eip
    42         movl 4(%esp),%edx       # address of the kernel_context variable to save context to
     42        movl 4(%esp),%edx       # address of the context variable to save context to
    4343
    4444        movl %esp,0(%edx)       # %esp -> ctx->sp
     
    6464#
    6565context_restore:
    66         movl 4(%esp),%eax       # address of the kernel_context variable to restore context from
     66        movl 4(%esp),%eax       # address of the context variable to restore context from
    6767        movl 0(%eax),%esp       # ctx->sp -> %esp
    6868        movl 4(%eax),%edx       # ctx->pc -> %edx
  • uspace/lib/libc/arch/ia64/Makefile.inc

    rb9641ee rbc1f1c2  
    3737
    3838ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
    39                 arch/$(ARCH)/src/psthread.S \
     39                arch/$(ARCH)/src/fibril.S \
    4040                arch/$(ARCH)/src/thread.c
    4141
  • uspace/lib/libc/arch/ia64/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_ia64_PSTHREAD_H_
    36 #define LIBC_ia64_PSTHREAD_H_
     35#ifndef LIBC_ia64_FIBRIL_H_
     36#define LIBC_ia64_FIBRIL_H_
    3737
    3838#include <types.h>
     
    4545 * No need to allocate scratch area.
    4646 */
    47 #define SP_DELTA        (0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
     47#define SP_DELTA        (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
    4848
    4949#define PFM_MASK        (~0x3fffffffff)
  • uspace/lib/libc/arch/ia64/include/thread.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_ia64THREAD_H_
    36 #define LIBC_ia64THREAD_H_
     35#ifndef LIBC_ia64_THREAD_H_
     36#define LIBC_ia64_THREAD_H_
    3737
    3838#define THREAD_INITIAL_STACK_PAGES_NO 2
     
    4141typedef struct {
    4242        void *dtv; /* unused in static linking*/
    43         void *pst_data;
     43        void *fibril_data;
    4444} tcb_t;
    4545
  • uspace/lib/libc/arch/mips32/Makefile.inc

    rb9641ee rbc1f1c2  
    4040
    4141ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    42         arch/$(ARCH)/src/psthread.S \
     42        arch/$(ARCH)/src/fibril.S \
    4343        arch/$(ARCH)/src/thread.c
    4444
  • uspace/lib/libc/arch/mips32/include/fibril.h

    rb9641ee rbc1f1c2  
    3434 */
    3535
    36 #ifndef LIBC_mips32_PSTHREAD_H_
    37 #define LIBC_mips32_PSTHREAD_H_
     36#ifndef LIBC_mips32_FIBRIL_H_
     37#define LIBC_mips32_FIBRIL_H_
    3838
    3939#include <types.h>
  • uspace/lib/libc/arch/mips32/include/thread.h

    rb9641ee rbc1f1c2  
    3636/* TLS for MIPS is described in http://www.linux-mips.org/wiki/NPTL */
    3737
    38 #ifndef LIBC_mips32THREAD_H_
    39 #define LIBC_mips32THREAD_H_
     38#ifndef LIBC_mips32_THREAD_H_
     39#define LIBC_mips32_THREAD_H_
    4040
    4141/* I did not find any specification (neither MIPS nor PowerPC), but
     
    5454
    5555typedef struct {
    56         void *pst_data;
     56        void *fibril_data;
    5757} tcb_t;
    5858
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    rb9641ee rbc1f1c2  
    3535
    3636ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    37                 arch/$(ARCH)/src/psthread.S \
     37                arch/$(ARCH)/src/fibril.S \
    3838                arch/$(ARCH)/src/thread.c
    3939
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    rb9641ee rbc1f1c2  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    36                 arch/$(ARCH)/src/psthread.S \
     36                arch/$(ARCH)/src/fibril.S \
    3737                arch/$(ARCH)/src/thread.c
    3838
  • uspace/lib/libc/arch/ppc32/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_ppc32_PSTHREAD_H_
    36 #define LIBC_ppc32_PSTHREAD_H_
     35#ifndef LIBC_ppc32_FIBRIL_H_
     36#define LIBC_ppc32_FIBRIL_H_
    3737
    3838#include <types.h>
  • uspace/lib/libc/arch/ppc32/include/thread.h

    rb9641ee rbc1f1c2  
    3939
    4040typedef struct {
    41         void *pst_data;
     41        void *fibril_data;
    4242} tcb_t;
    4343
  • uspace/lib/libc/arch/ppc64/Makefile.inc

    rb9641ee rbc1f1c2  
    3434
    3535ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
    36                 arch/$(ARCH)/src/psthread.S \
     36                arch/$(ARCH)/src/fibril.S \
    3737                arch/$(ARCH)/src/thread.c
    3838
  • uspace/lib/libc/arch/ppc64/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_ppc64_PSTHREAD_H_
    36 #define LIBC_ppc64_PSTHREAD_H_
     35#ifndef LIBC_ppc64_FIBRIL_H_
     36#define LIBC_ppc64_FIBRIL_H_
    3737
    3838#include <types.h>
  • uspace/lib/libc/arch/ppc64/include/thread.h

    rb9641ee rbc1f1c2  
    3939
    4040typedef struct {
    41         void *pst_data;
     41        void *fibril_data;
    4242} tcb_t;
    4343
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    rb9641ee rbc1f1c2  
    3333TOOLCHAIN_DIR = /usr/local/sparc64/bin
    3434
    35 ARCH_SOURCES += arch/$(ARCH)/src/psthread.S \
     35ARCH_SOURCES += arch/$(ARCH)/src/fibril.S \
    3636                arch/$(ARCH)/src/thread.c
    3737
  • uspace/lib/libc/arch/sparc64/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_sparc64_PSTHREAD_H_
    36 #define LIBC_sparc64_PSTHREAD_H_
     35#ifndef LIBC_sparc64_FIBRIL_H_
     36#define LIBC_sparc64_FIBRIL_H_
    3737
    3838#include <libarch/stack.h>
  • uspace/lib/libc/arch/sparc64/include/thread.h

    rb9641ee rbc1f1c2  
    4141typedef struct {
    4242        void *self;
    43         void *pst_data;
     43        void *fibril_data;
    4444} tcb_t;
    4545
  • uspace/lib/libc/generic/async.c

    rb9641ee rbc1f1c2  
    8686 * }
    8787 *
    88  * TODO: Detaching/joining dead psthreads?
    8988 */
    9089#include <futex.h>
    9190#include <async.h>
    92 #include <psthread.h>
     91#include <fibril.h>
    9392#include <stdio.h>
    9493#include <libadt/hash_table.h>
     
    105104
    106105typedef struct {
    107         struct timeval expires;         /**< Expiration time for waiting thread */
    108         int inlist;                     /**< If true, this struct is in timeout list */
     106        /** Expiration time for waiting fibril. */
     107        struct timeval expires;         
     108        /** If true, this struct is in the timeout list. */
     109        int inlist;
    109110        link_t link;
    110111
    111         pstid_t ptid;                   /**< Thread waiting for this message */
    112         int active;                     /**< If this thread is currently active */
    113         int timedout;                   /**< If true, we timed out */
     112        /** Fibril waiting for this message. */
     113        fid_t fid;
     114        /** If this fibril is currently active. */
     115        int active;
     116        /** If true, we timed out. */
     117        int timedout;
    114118} awaiter_t;
    115119
     
    119123        int done;                       /**< If reply was received */
    120124        ipc_call_t *dataptr;            /**< Pointer where the answer data
    121                                           *   is stored */
     125                                         *   is stored */
    122126        ipcarg_t retval;
    123127} amsg_t;
     
    132136        awaiter_t wdata;
    133137
    134         link_t link;                    /**< Hash table link */
     138        link_t link;                    /**< Hash table link. */
    135139        ipcarg_t in_phone_hash;         /**< Incoming phone hash. */
    136         link_t msg_queue;               /**< Messages that should be delivered to this thread */
     140        link_t msg_queue;               /**< Messages that should be delivered
     141                                         *   to this fibril. */
    137142        /* Structures for connection opening packet */
    138143        ipc_callid_t callid;
    139144        ipc_call_t call;
    140         ipc_callid_t close_callid;      /* Identification of closing packet */
    141         void (*cthread)(ipc_callid_t,ipc_call_t *);
     145        ipc_callid_t close_callid;      /* Identification of closing packet. */
     146        void (*cfibril)(ipc_callid_t, ipc_call_t *);
    142147} connection_t;
    143148
    144 /** Identifier of incoming connection handled by current thread */
    145 __thread connection_t *PS_connection;
     149/** Identifier of the incoming connection handled by the current fibril. */
     150__thread connection_t *FIBRIL_connection;
    146151/** If true, it is forbidden to use async_req functions and
    147152 *  all preemption is disabled */
     
    286291                }
    287292                conn->wdata.active = 1;
    288                 psthread_add_ready(conn->wdata.ptid);
     293                fibril_add_ready(conn->wdata.fid);
    289294        }
    290295
     
    301306        connection_t *conn;
    302307       
    303         assert(PS_connection);
    304         /* GCC 4.1.0 coughs on PS_connection-> dereference,
     308        assert(FIBRIL_connection);
     309        /* GCC 4.1.0 coughs on FIBRIL_connection-> dereference,
    305310         * GCC 4.1.1 happilly puts the rdhwr instruction in delay slot.
    306311         *           I would never expect to find so many errors in
    307312         *           compiler *($&$(*&$
    308313         */
    309         conn = PS_connection;
     314        conn = FIBRIL_connection;
    310315
    311316        futex_down(&async_futex);
     
    323328
    324329                conn->wdata.active = 0;
    325                 psthread_schedule_next_adv(PS_TO_MANAGER);
     330                fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
    326331                /* Futex is up after getting back from async_manager
    327332                 * get it again */
    328333                futex_down(&async_futex);
    329                 if (usecs && conn->wdata.timedout && \
     334                if (usecs && conn->wdata.timedout &&
    330335                    list_empty(&conn->msg_queue)) {
    331336                        /* If we timed out-> exit */
     
    365370 * @param arg Connection structure pointer
    366371 */
    367 static int connection_thread(void  *arg)
     372static int connection_fibril(void  *arg)
    368373{
    369374        unsigned long key;
     
    372377
    373378        /* Setup thread local connection pointer */
    374         PS_connection = (connection_t *)arg;
    375         PS_connection->cthread(PS_connection->callid, &PS_connection->call);
     379        FIBRIL_connection = (connection_t *) arg;
     380        FIBRIL_connection->cfibril(FIBRIL_connection->callid,
     381            &FIBRIL_connection->call);
    376382       
    377383        /* Remove myself from connection hash table */
    378384        futex_down(&async_futex);
    379         key = PS_connection->in_phone_hash;
     385        key = FIBRIL_connection->in_phone_hash;
    380386        hash_table_remove(&conn_hash_table, &key, 1);
    381387        futex_up(&async_futex);
    382388       
    383389        /* Answer all remaining messages with ehangup */
    384         while (!list_empty(&PS_connection->msg_queue)) {
    385                 msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link);
     390        while (!list_empty(&FIBRIL_connection->msg_queue)) {
     391                msg = list_get_instance(FIBRIL_connection->msg_queue.next,
     392                    msg_t, link);
    386393                list_remove(&msg->link);
    387                 if (msg->callid == PS_connection->close_callid)
     394                if (msg->callid == FIBRIL_connection->close_callid)
    388395                        close_answered = 1;
    389396                ipc_answer_fast(msg->callid, EHANGUP, 0, 0);
    390397                free(msg);
    391398        }
    392         if (PS_connection->close_callid)
    393                 ipc_answer_fast(PS_connection->close_callid, 0, 0, 0);
     399        if (FIBRIL_connection->close_callid)
     400                ipc_answer_fast(FIBRIL_connection->close_callid, 0, 0, 0);
    394401       
    395402        return 0;
     
    406413 * @param callid Callid of the IPC_M_CONNECT_ME_TO packet
    407414 * @param call Call data of the opening packet
    408  * @param cthread Thread function that should be called upon
     415 * @param cfibril Fibril function that should be called upon
    409416 *                opening the connection
    410  * @return New thread id
    411  */
    412 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *))
     417 * @return New fibril id.
     418 */
     419fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
     420    ipc_call_t *call, void (*cfibril)(ipc_callid_t, ipc_call_t *))
    413421{
    414422        connection_t *conn;
     
    427435                conn->call = *call;
    428436        conn->wdata.active = 1; /* We will activate it asap */
    429         conn->cthread = cthread;
    430 
    431         conn->wdata.ptid = psthread_create(connection_thread, conn);
    432         if (!conn->wdata.ptid) {
     437        conn->cfibril = cfibril;
     438
     439        conn->wdata.fid = fibril_create(connection_fibril, conn);
     440        if (!conn->wdata.fid) {
    433441                free(conn);
    434442                ipc_answer_fast(callid, ENOMEM, 0, 0);
     
    441449        futex_up(&async_futex);
    442450
    443         psthread_add_ready(conn->wdata.ptid);
    444 
    445         return conn->wdata.ptid;
     451        fibril_add_ready(conn->wdata.fid);
     452
     453        return conn->wdata.fid;
    446454}
    447455
     
    460468        case IPC_M_CONNECT_ME_TO:
    461469                /* Open new connection with thread etc. */
    462                 async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection);
     470                async_new_connection(IPC_GET_ARG3(*call), callid, call,
     471                    client_connection);
    463472                return;
    464473        }
     
    486495        cur = timeout_list.next;
    487496        while (cur != &timeout_list) {
    488                 waiter = list_get_instance(cur,awaiter_t,link);
     497                waiter = list_get_instance(cur, awaiter_t, link);
    489498                if (tv_gt(&waiter->expires, &tv))
    490499                        break;
     
    498507                if (!waiter->active) {
    499508                        waiter->active = 1;
    500                         psthread_add_ready(waiter->ptid);
     509                        fibril_add_ready(waiter->fid);
    501510                }
    502511        }
     
    515524
    516525        while (1) {
    517                 if (psthread_schedule_next_adv(PS_FROM_MANAGER)) {
     526                if (fibril_schedule_next_adv(FIBRIL_FROM_MANAGER)) {
    518527                        futex_up(&async_futex);
    519528                        /* async_futex is always held
     
    524533                futex_down(&async_futex);
    525534                if (!list_empty(&timeout_list)) {
    526                         waiter = list_get_instance(timeout_list.next,awaiter_t,link);
    527                         gettimeofday(&tv,NULL);
     535                        waiter = list_get_instance(timeout_list.next, awaiter_t,
     536                            link);
     537                        gettimeofday(&tv, NULL);
    528538                        if (tv_gteq(&tv, &waiter->expires)) {
    529539                                futex_up(&async_futex);
     
    573583void async_create_manager(void)
    574584{
    575         pstid_t ptid;
    576 
    577         ptid = psthread_create(async_manager_thread, NULL);
    578         psthread_add_manager(ptid);
     585        fid_t fid;
     586
     587        fid = fibril_create(async_manager_thread, NULL);
     588        fibril_add_manager(fid);
    579589}
    580590
     
    582592void async_destroy_manager(void)
    583593{
    584         psthread_remove_manager();
     594        fibril_remove_manager();
    585595}
    586596
     
    588598int _async_init(void)
    589599{
    590         if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_CHAINS, 1, &conn_hash_table_ops)) {
     600        if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_CHAINS, 1,
     601            &conn_hash_table_ops)) {
    591602                printf("%s: cannot create hash table\n", "async");
    592603                return ENOMEM;
     
    598609/** IPC handler for messages in async framework
    599610 *
    600  * Notify thread that is waiting for this message, that it arrived
     611 * Notify the fibril which is waiting for this message, that it arrived
    601612 */
    602613static void reply_received(void *private, int retval,
     
    621632        if (! msg->wdata.active) {
    622633                msg->wdata.active = 1;
    623                 psthread_add_ready(msg->wdata.ptid);
     634                fibril_add_ready(msg->wdata.fid);
    624635        }
    625636        futex_up(&async_futex);
     
    633644aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
    634645                   ipc_call_t *dataptr)
     646{
     647        amsg_t *msg;
     648
     649        if (in_interrupt_handler) {
     650                printf("Cannot send asynchronous request in interrupt "
     651                    "handler.\n");
     652                _exit(1);
     653        }
     654
     655        msg = malloc(sizeof(*msg));
     656        msg->done = 0;
     657        msg->dataptr = dataptr;
     658
     659        msg->wdata.active = 1; /* We may sleep in next method, but it
     660                                * will use it's own mechanism */
     661        ipc_call_async_2(phoneid, method, arg1, arg2, msg, reply_received, 1);
     662
     663        return (aid_t) msg;
     664}
     665
     666/** Send message and return id of the sent message
     667 *
     668 * The return value can be used as input for async_wait() to wait
     669 * for completion.
     670 */
     671aid_t async_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
     672                   ipcarg_t arg3, ipc_call_t *dataptr)
    635673{
    636674        amsg_t *msg;
     
    647685        msg->wdata.active = 1; /* We may sleep in next method, but it
    648686                                * will use it's own mechanism */
    649         ipc_call_async_2(phoneid,method,arg1,arg2,msg,reply_received,1);
    650 
    651         return (aid_t) msg;
    652 }
    653 
    654 /** Send message and return id of the sent message
    655  *
    656  * The return value can be used as input for async_wait() to wait
    657  * for completion.
    658  */
    659 aid_t async_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
    660                    ipcarg_t arg3, ipc_call_t *dataptr)
    661 {
    662         amsg_t *msg;
    663 
    664         if (in_interrupt_handler) {
    665                 printf("Cannot send asynchronous request in interrupt handler.\n");
    666                 _exit(1);
    667         }
    668 
    669         msg = malloc(sizeof(*msg));
    670         msg->done = 0;
    671         msg->dataptr = dataptr;
    672 
    673         msg->wdata.active = 1; /* We may sleep in next method, but it
    674                                 * will use it's own mechanism */
    675         ipc_call_async_3(phoneid,method,arg1,arg2,arg3, msg,reply_received,1);
     687        ipc_call_async_3(phoneid, method, arg1, arg2, arg3, msg, reply_received,
     688            1);
    676689
    677690        return (aid_t) msg;
     
    695708        }
    696709
    697         msg->wdata.ptid = psthread_get_id();
     710        msg->wdata.fid = fibril_get_id();
    698711        msg->wdata.active = 0;
    699712        msg->wdata.inlist = 0;
    700713        /* Leave locked async_futex when entering this function */
    701         psthread_schedule_next_adv(PS_TO_MANAGER);
    702         /* futex is up automatically after psthread_schedule_next...*/
     714        fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
     715        /* futex is up automatically after fibril_schedule_next...*/
    703716done:
    704717        if (retval)
     
    733746        tv_add(&msg->wdata.expires, timeout);
    734747
    735         msg->wdata.ptid = psthread_get_id();
     748        msg->wdata.fid = fibril_get_id();
    736749        msg->wdata.active = 0;
    737750        insert_timeout(&msg->wdata);
    738751
    739752        /* Leave locked async_futex when entering this function */
    740         psthread_schedule_next_adv(PS_TO_MANAGER);
    741         /* futex is up automatically after psthread_schedule_next...*/
     753        fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
     754        /* futex is up automatically after fibril_schedule_next...*/
    742755
    743756        if (!msg->done)
     
    769782                return;
    770783
    771         msg->wdata.ptid = psthread_get_id();
     784        msg->wdata.fid = fibril_get_id();
    772785        msg->wdata.active = 0;
    773786
     
    778791        insert_timeout(&msg->wdata);
    779792        /* Leave locked async_futex when entering this function */
    780         psthread_schedule_next_adv(PS_TO_MANAGER);
    781         /* futex is up automatically after psthread_schedule_next...*/
     793        fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
     794        /* futex is up automatically after fibril_schedule_next...*/
    782795        free(msg);
    783796}
     
    800813                 ipcarg_t arg2, ipcarg_t arg3)
    801814{
    802         ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, !in_interrupt_handler);
     815        ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL,
     816            !in_interrupt_handler);
    803817}
    804818
    805819void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2)
    806820{
    807         ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, !in_interrupt_handler);
     821        ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL,
     822            !in_interrupt_handler);
    808823}
    809824
  • uspace/lib/libc/generic/ipc.c

    rb9641ee rbc1f1c2  
    5050#include <kernel/synch/synch.h>
    5151#include <async.h>
    52 #include <psthread.h>
     52#include <fibril.h>
    5353
    5454/** Structure used for keeping track of sent asynchronous calls and queing
     
    6767                } msg;
    6868        } u;
    69         pstid_t ptid;   /**< Pseudothread waiting for sending this call. */
     69        fid_t fid;      /**< Fibril waiting for sending this call. */
    7070} async_call_t;
    7171
     
    217217
    218218                if (can_preempt) {
    219                         call->ptid = psthread_get_id();
    220                         psthread_schedule_next_adv(PS_TO_MANAGER);
     219                        call->fid = fibril_get_id();
     220                        fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
    221221                        /* Async futex unlocked by previous call */
    222222                } else {
    223                         call->ptid = 0;
     223                        call->fid = 0;
    224224                        futex_up(&async_futex);
    225225                }
     
    384384
    385385                futex_up(&async_futex);
    386                 if (call->ptid)
    387                         psthread_add_ready(call->ptid);
     386                if (call->fid)
     387                        fibril_add_ready(call->fid);
    388388               
    389389                if (callid == IPC_CALLRET_FATAL) {
  • uspace/lib/libc/generic/libc.c

    rb9641ee rbc1f1c2  
    4343#include <thread.h>
    4444#include <malloc.h>
    45 #include <psthread.h>
     45#include <fibril.h>
    4646#include <io/stream.h>
    4747#include <ipc/ipc.h>
     
    5858void __main(void)
    5959{
    60         psthread_data_t *pt;
     60        fibril_t *f;
    6161
    6262        (void) as_area_create(&_heap, 1, AS_AREA_WRITE | AS_AREA_READ);
    6363        _async_init();
    64         pt = psthread_setup();
    65         __tcb_set(pt->tcb);
     64        f = fibril_setup();
     65        __tcb_set(f->tcb);
    6666}
    6767
     
    7575void __exit(void)
    7676{
    77         psthread_teardown(__tcb_get()->pst_data);
     77        fibril_teardown(__tcb_get()->fibril_data);
    7878        _exit(0);
    7979}
  • uspace/lib/libc/generic/thread.c

    rb9641ee rbc1f1c2  
    3838#include <libarch/faddr.h>
    3939#include <kernel/proc/uarg.h>
    40 #include <psthread.h>
     40#include <fibril.h>
    4141#include <string.h>
    4242#include <async.h>
     
    101101void __thread_main(uspace_arg_t *uarg)
    102102{
    103         psthread_data_t *pt;
    104 
    105         pt = psthread_setup();
    106         __tcb_set(pt->tcb);
     103        fibril_t *f;
     104
     105        f = fibril_setup();
     106        __tcb_set(f->tcb);
    107107       
    108108        uarg->uspace_thread_function(uarg->uspace_thread_arg);
     
    113113        /* If there is a manager, destroy it */
    114114        async_destroy_manager();
    115         psthread_teardown(pt);
     115        fibril_teardown(f);
    116116
    117117        thread_exit(0);
  • uspace/lib/libc/include/async.h

    rb9641ee rbc1f1c2  
    3737
    3838#include <ipc/ipc.h>
    39 #include <psthread.h>
     39#include <fibril.h>
    4040#include <sys/time.h>
    4141#include <atomic.h>
     
    4646static inline void async_manager(void)
    4747{
    48         psthread_schedule_next_adv(PS_TO_MANAGER);
     48        fibril_schedule_next_adv(FIBRIL_TO_MANAGER);
    4949}
    5050
     
    102102
    103103
    104 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
     104fid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
    105105                             ipc_call_t *call,
    106106                             void (*cthread)(ipc_callid_t,ipc_call_t *));
     
    121121static inline void async_serialize_start(void)
    122122{
    123         psthread_inc_sercount();
     123        fibril_inc_sercount();
    124124}
    125125
    126126static inline void async_serialize_end(void)
    127127{
    128         psthread_dec_sercount();
     128        fibril_dec_sercount();
    129129}
    130130
  • uspace/lib/libc/include/fibril.h

    rb9641ee rbc1f1c2  
    3333 */
    3434
    35 #ifndef LIBC_PSTHREAD_H_
    36 #define LIBC_PSTHREAD_H_
     35#ifndef LIBC_FIBRIL_H_
     36#define LIBC_FIBRIL_H_
    3737
    38 #include <libarch/psthread.h>
     38#include <libarch/fibril.h>
    3939#include <libadt/list.h>
    4040#include <libarch/thread.h>
     
    4747#endif /* context_set */
    4848
    49 #define PSTHREAD_SERIALIZED   1
     49#define FIBRIL_SERIALIZED   1
    5050
    5151typedef enum {
    52         PS_SLEEP,
    53         PS_PREEMPT,
    54         PS_TO_MANAGER,
    55         PS_FROM_MANAGER,
    56         PS_FROM_DEAD
    57 } pschange_type;
     52        FIBRIL_SLEEP,
     53        FIBRIL_PREEMPT,
     54        FIBRIL_TO_MANAGER,
     55        FIBRIL_FROM_MANAGER,
     56        FIBRIL_FROM_DEAD
     57} fibril_switch_type_t;
    5858
    59 typedef sysarg_t pstid_t;
     59typedef sysarg_t fid_t;
    6060
    61 struct psthread_data {
     61struct fibril {
    6262        link_t link;
    6363        context_t ctx;
     
    6767        tcb_t *tcb;
    6868
    69         struct psthread_data *clean_after_me;
    70         struct psthread_data *joiner;
     69        struct fibril *clean_after_me;
     70        struct fibril *joiner;
    7171        int joinee_retval;
    7272        int retval;
    7373        int flags;
    7474};
    75 typedef struct psthread_data psthread_data_t;
     75typedef struct fibril fibril_t;
    7676
    7777extern int context_save(context_t *c);
    7878extern void context_restore(context_t *c) __attribute__ ((noreturn));
    7979
    80 pstid_t psthread_create(int (*func)(void *), void *arg);
    81 int psthread_join(pstid_t psthrid);
    82 psthread_data_t * psthread_setup(void);
    83 void psthread_teardown(psthread_data_t *pt);
    84 int psthread_schedule_next_adv(pschange_type ctype);
    85 void psthread_add_ready(pstid_t ptid);
    86 void psthread_add_manager(pstid_t psthrid);
    87 void psthread_remove_manager(void);
    88 pstid_t psthread_get_id(void);
    89 void psthread_inc_sercount(void);
    90 void psthread_dec_sercount(void);
     80extern fid_t fibril_create(int (*func)(void *), void *arg);
     81extern int fibril_join(fid_t fid);
     82extern fibril_t *fibril_setup(void);
     83extern void fibril_teardown(fibril_t *f);
     84extern int fibril_schedule_next_adv(fibril_switch_type_t stype);
     85extern void fibril_add_ready(fid_t fid);
     86extern void fibril_add_manager(fid_t fid);
     87extern void fibril_remove_manager(void);
     88extern fid_t fibril_get_id(void);
     89extern void fibril_inc_sercount(void);
     90extern void fibril_dec_sercount(void);
    9191
    92 static inline int psthread_schedule_next(void) {
    93         return psthread_schedule_next_adv(PS_PREEMPT);
     92static inline int fibril_schedule_next(void) {
     93        return fibril_schedule_next_adv(FIBRIL_PREEMPT);
    9494}
    9595
Note: See TracChangeset for help on using the changeset viewer.