Re: Mutex Problem (Or Anything Else) in SMP Scheduling
Posted: Sat May 06, 2017 9:26 pm
Before creating the topic, I've already got a structure of thread and process:Brendan wrote:at the end of this post.[/i]
Code: Select all
typedef struct s_regs
{
qword r15, r14, r13, r12, r11, r10, r9, r8;
qword rdi, rsi, rbp, kernel_rsp, rdx, rbx, rcx, rax;
qword Rsvd;
qword rip, cs, rflags, rsp, ss;
} RegImage;
typedef enum e_tstate
{
Created = 0,
Ready = 1,
Running = 2,
Waiting = 3,
Halted = 4
} ThrdState;
typedef struct s_thrd
{
RegImage Regs;
short TId;
Action Entry;
short ParentId;
short ProcId;
ThrdState State;
int Priority;
int Ticks;
} Thread;
typedef struct s_proc
{
short PId;
int UserId;
char Name[16];
int ThreadsId[MAX_THRD_PER_PROC];
} Process;
Code: Select all
public int DeriveT(int tid, int pcsr, Action entry, int priority);//'public' is a macro defined nothing and 'private' is defined as 'static'
Code: Select all
public int Init()
{
while(1)
{
DispStr("I.");
LittleDelay();
}
}
public int Child1()
{
while(1)
{
DispStr("A.");
LittleDelay();
}
}
public int Child2()
{
while(1)
{
DispStr("B.");
LittleDelay();
}
}
Code: Select all
Restart:
lldt [rel LdtSel]
mov rax, [rel CurrentT]
mov rsp, [rax]
lea rax, [rsp + 22 * 8]
mov rbx, 0xFFFFFF8000601800
mov qword [rbx + 4], rax
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
add rsp, 8
pop rbx
pop rdx
pop rcx
pop rax
add rsp, 8
mov rdi, RestartLock
call LeaveSpinLock
iretq
So hasn't the code above got any mistakes?