Subversion Repositories HelenOS

Rev

Rev 2568 | Rev 3565 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2568 Rev 2586
Line 39... Line 39...
39
#include <kernel/proc/uarg.h>
39
#include <kernel/proc/uarg.h>
40
#include <fibril.h>
40
#include <fibril.h>
41
#include <string.h>
41
#include <string.h>
42
#include <async.h>
42
#include <async.h>
43
 
43
 
44
#include <stdio.h>
-
 
45
 
-
 
46
 
-
 
47
#ifndef THREAD_INITIAL_STACK_PAGES_NO
44
#ifndef THREAD_INITIAL_STACK_PAGES_NO
48
#define THREAD_INITIAL_STACK_PAGES_NO 1
45
#define THREAD_INITIAL_STACK_PAGES_NO 1
49
#endif
46
#endif
50
 
47
 
51
static LIST_INITIALIZE(thread_garbage);
-
 
52
 
-
 
53
extern char _tdata_start;
-
 
54
extern char _tdata_end;
-
 
55
extern char _tbss_start;
-
 
56
extern char _tbss_end;
-
 
57
 
-
 
58
/** Create TLS (Thread Local Storage) data structures.
-
 
59
 *
-
 
60
 * The code requires, that sections .tdata and .tbss are adjacent. It may be
-
 
61
 * changed in the future.
-
 
62
 *
-
 
63
 * @return Pointer to TCB.
-
 
64
 */
-
 
65
tcb_t *__make_tls(void)
-
 
66
{
-
 
67
    void *data;
-
 
68
    tcb_t *tcb;
-
 
69
    size_t tls_size = &_tbss_end - &_tdata_start;
-
 
70
   
-
 
71
    tcb = __alloc_tls(&data, tls_size);
-
 
72
   
-
 
73
    /*
-
 
74
     * Copy thread local data from the initialization image.
-
 
75
     */
-
 
76
    memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start);
-
 
77
    /*
-
 
78
     * Zero out the thread local uninitialized data.
-
 
79
     */
-
 
80
    memset(data + (&_tbss_start - &_tdata_start), 0,
-
 
81
        &_tbss_end - &_tbss_start);
-
 
82
 
-
 
83
    return tcb;
-
 
84
}
-
 
85
 
-
 
86
void __free_tls(tcb_t *tcb)
-
 
87
{
-
 
88
    size_t tls_size = &_tbss_end - &_tdata_start;
-
 
89
    __free_tls_arch(tcb, tls_size);
-
 
90
}
-
 
91
 
-
 
92
/** Main thread function.
48
/** Main thread function.
93
 *
49
 *
94
 * This function is called from __thread_entry() and is used
50
 * This function is called from __thread_entry() and is used
95
 * to call the thread's implementing function and perform cleanup
51
 * to call the thread's implementing function and perform cleanup
96
 * and exit when thread returns back. Do not call this function
52
 * and exit when thread returns back. Do not call this function