Changeset 86d05fae in mainline


Ignore:
Timestamp:
2006-03-24T11:05:41Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4f2c821
Parents:
a71d9af9
Message:

TLS and pseudo thread support for ia64.

Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    ra71d9af9 r86d05fae  
    275275        version_print();
    276276
    277 /*      test_printf(); */
     277//      test_printf();
    278278//      test_ping();
    279279//      test_async_ipc();
     
    289289                printf("Futex failed.\n");
    290290
    291         if ((tid = thread_create(utest, NULL, "utest") != -1)) {
     291        if (futex_down(&ftx) < 0)
     292                printf("Futex failed.\n");
     293
     294        if ((tid = thread_create(utest, NULL, "utest")) != -1) {
    292295                printf("Created thread tid=%d\n", tid);
    293296        }
    294297
    295         if (futex_down(&ftx) < 0)
    296                 printf("Futex failed.\n");
    297 
    298         if ((tid = thread_create(utest, NULL, "utest") != -1)) {
     298        if ((tid = thread_create(utest, NULL, "utest")) != -1) {
    299299                printf("Created thread tid=%d\n", tid);
    300300        }
     
    302302        int i;
    303303       
    304         for (i = 0; i < 10000000; i++)
     304        for (i = 0; i < 50000000; i++)
    305305                ;
    306306               
     
    309309
    310310        ptid = psthread_create(ptest, NULL);
    311         printf("Main thread-1\n");
    312         ps_preempt();
    313         printf("Main thread-2\n");
     311        printf("main thread-1\n");
     312        ps_preempt();
     313        printf("main thread-2\n");
    314314        ps_preempt();
    315315        printf("main thread-3\n");
  • libc/arch/ia64/Makefile.inc

    ra71d9af9 r86d05fae  
    3636AFLAGS +=
    3737
    38 ARCH_SOURCES += arch/$(ARCH)/src/syscall.S
     38ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \
     39                arch/$(ARCH)/src/psthread.S
  • libc/generic/psthread.c

    ra71d9af9 r86d05fae  
    3333#include <thread.h>
    3434#include <stdio.h>
     35#include <kernel/arch/faddr.h>
    3536
    3637static LIST_INITIALIZE(ready_list);
     38
     39static void ps_exit(void) __attribute__ ((noinline));
    3740
    3841/** Function to preempt to other thread without adding
    3942 * currently running thread to runqueue
    4043 */
    41 static void ps_exit(void)
     44void ps_exit(void)
    4245{
    4346        psthread_data_t *pt;
     
    8891int ps_join(pstid_t psthrid)
    8992{
    90         psthread_data_t *pt, *mypt;
    91         int retval;
     93        volatile psthread_data_t *pt, *mypt;
     94        volatile int retval;
    9295
    9396        /* Handle psthrid = Kernel address -> it is wait for call */
     
    97100        if (!pt->finished) {
    98101                mypt = __tls_get();
    99                 if (context_save(&mypt->ctx)) {
    100                         pt->waiter = mypt;
     102                if (context_save(&((psthread_data_t *) mypt)->ctx)) {
     103                        pt->waiter = (psthread_data_t *) mypt;
    101104                        ps_exit();
    102105                }
     
    105108
    106109        free(pt->stack);
    107         __free_tls(pt);
     110        __free_tls((psthread_data_t *) pt);
    108111
    109112        return retval;
     
    131134
    132135        context_save(&pt->ctx);
    133         context_set(&pt->ctx, psthread_main, pt->stack, getpagesize(), pt);
     136        context_set(&pt->ctx, FADDR(psthread_main), pt->stack, getpagesize(), pt);
    134137
    135138        list_append(&pt->list, &ready_list);
  • libc/include/psthread.h

    ra71d9af9 r86d05fae  
    3434
    3535#ifndef context_set
    36 #define context_set(c, _pc, stack, size, ptls)  \
    37         (c)->pc = (sysarg_t) (_pc);             \
    38         (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     36#define context_set(c, _pc, stack, size, ptls)                  \
     37        (c)->pc = (sysarg_t) (_pc);                             \
     38        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
    3939        (c)->tls = (sysarg_t) (ptls);
    4040#endif /* context_set */
     
    4343
    4444struct psthread_data {
    45         struct psthread_data *self; /* IA32,AMD64 needs to get self address */
     45        struct psthread_data *self; /* ia32, amd64 needs to get self address */
    4646
    4747        link_t list;
  • libc/include/stdarg.h

    ra71d9af9 r86d05fae  
    4545
    4646#endif
     47
  • libc/include/stdlib.h

    ra71d9af9 r86d05fae  
    3030#define __LIBC__STDLIB_H__
    3131
     32#include <unistd.h>
    3233#include <malloc.h>
    3334
Note: See TracChangeset for help on using the changeset viewer.