aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/include/x86/arch_sched.h
blob: 877440762e01c0d5547bd5c74b80d1c4ef40c1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef __ARCH_SCHED_H__
#define __ARCH_SCHED_H__

#include <arch_mm.h>

static inline struct thread* get_current(void)
{
    struct thread **current;
#ifdef __i386__    
    register unsigned long sp asm("esp");
#else
    register unsigned long sp asm("rsp");
#endif 
    current = (void *)(unsigned long)(sp & ~(STACK_SIZE-1));
    return *current;
}

extern void __arch_switch_threads(unsigned long *prevctx, unsigned long *nextctx);

#define arch_switch_threads(prev,next) __arch_switch_threads(&(prev)->sp, &(next)->sp)


          
#endif /* __ARCH_SCHED_H__ */