Subversion Repositories Kolibri OS

Rev

Rev 928 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 928 Rev 1066
1
#include 
1
#include 
2
#include 
2
#include 
3
#include 
3
#include 
4
#include 
4
#include 
5
#include 
5
#include 
6
#include 
6
#include 
7
 
7
 
8
addr_t thr_ptr;
8
addr_t thr_ptr;
9
 
9
 
10
slab_cache_t *thr_slab;
10
slab_cache_t *thr_slab;
11
 
11
 
12
extern addr_t sys_pdbr;
12
extern addr_t sys_pdbr;
13
 
13
 
14
void init_threads()
14
void init_threads()
15
{
15
{
16
    thr_slab = slab_cache_create(sizeof(thr_t), 16,
16
    DBG("%s\n", __FUNCTION__);
-
 
17
 
-
 
18
    thr_slab = slab_cache_create(sizeof(thr_t), 16,
17
               NULL,NULL,SLAB_CACHE_MAGDEFERRED);
19
               NULL,NULL,SLAB_CACHE_MAGDEFERRED);
18
};
20
};
19
 
21
 
20
 
22
 
21
thr_t* __fastcall create_systhread(addr_t entry_ptr)
23
thr_t* __fastcall create_systhread(addr_t entry_ptr)
22
{
24
{
23
    static count_t  thr_cnt = 0;
25
    static count_t  thr_cnt = 0;
24
    static count_t  slot = 1;
26
    static count_t  slot = 1;
25
 
27
 
26
    thr_t   *thr;
28
    thr_t   *thr;
27
    addr_t   thr_stack;
29
    addr_t   thr_stack;
28
 
30
 
-
 
31
    DBG("%s\n", __FUNCTION__);
-
 
32
 
29
    thr = (thr_t*)slab_alloc(thr_slab,0);
33
    thr = (thr_t*)slab_alloc(thr_slab,0);
30
    thr_stack = PA2KA(core_alloc(1));
34
    thr_stack = PA2KA(frame_alloc(2));
31
 
35
 
32
    thr_cnt++;
36
    thr_cnt++;
33
 
37
 
34
    thr->eax = (thr_cnt<<8)|slot;
38
    thr->eax = (thr_cnt<<8)|slot;
35
    thr->tid = (thr_cnt<<8)|slot;
39
    thr->tid = (thr_cnt<<8)|slot;
36
 
40
 
37
    thr->slot = slot;
41
    thr->slot = slot;
38
 
42
 
39
    slot++;
43
    slot++;
40
 
44
 
41
    thr->pdir = KA2PA(&sys_pdbr);
45
    thr->pdir = KA2PA(&sys_pdbr);
42
 
46
 
43
    thr->ebx = 0;
47
    thr->ebx = 0;
44
 
48
 
45
    thr->edi = 0;
49
    thr->edi = 0;
46
    thr->esi = 0;
50
    thr->esi = 0;
47
    thr->ebp = 0;
51
    thr->ebp = 0;
48
    thr->edx = 0;
52
    thr->edx = 0;
49
    thr->ecx = 0;
53
    thr->ecx = 0;
50
 
54
 
51
    thr->cs  = sel_srv_code;
55
    thr->cs  = sel_srv_code;
52
    thr->eflags = EFL_IOPL1;
56
    thr->eflags = EFL_IOPL1;
53
    thr->esp = thr_stack + 8192;
57
    thr->esp = thr_stack + 8192;
54
    thr->ss = sel_srv_stack;
58
    thr->ss = sel_srv_stack;
55
 
59
 
56
    thr->thr_flags    = 0;
60
    thr->thr_flags    = 0;
57
 
61
 
58
    thr->ticks_left   = 8;
62
    thr->ticks_left   = 8;
59
    thr->quantum_size = 8;
63
    thr->quantum_size = 8;
60
 
64
 
61
    thr->eip = entry_ptr;
65
    thr->eip = entry_ptr;
62
 
66
 
63
    //lock_enqueue(thr_ptr);       /* add to scheduling queues */
67
    //lock_enqueue(thr_ptr);       /* add to scheduling queues */
64
 
68
 
65
    return thr;
69
    return thr;
66
};
70
};
67
 
71
 
68
>
72
>
69
 
73
 
70
>
74
>
71
>
75
>
72
>
76
>