#Nyaux
1 messages · Page 46 of 1
was to why we page fault
its a stupid issue really
on sched_yield i never push the userspace regs
i just assume its already been done
therefore im corrupting the stack
@surreal path is it true what nyaux supports 64 bit hpet ????!!?!!!
it supports both 32 bit and 64 bit hpet now
@kind root you would agree this is pretty dumb correct
only thing you have to be careful with 32-bit hpet is overflow
yea i think i solved that
I wonder how do you even solve that, I haven't really though about it
like if the counter wraps around every 7 minutes or whatever (with 10mhz) and a thread sleeps for 8 minutes
yeah you don't but its something that I am not completely sure how do you solve
anyways u would agree this probs caused the issue
if you don't save them somewhere else like an interrupt frame then probably
yep
and also i still dont understand @flat nymph thing he found that is an issue
or well with my design
ill have to ask him more questions on that in the meantime
im wayyyyy too hurt to work my finger hurts typing this
😭
looks like a normal bug
actually nvm, I guess you just install an irq and then you keep some kind of 64-bit offset to which you add the current counter value when reading and when you get a wrap irq you increment that by UINT32_MAX?
In non-periodic mode, the OS programs one of timer's comparator registers with value of main counter that is to trigger an interrupt. If the timer is set to 32 bit mode, it will also generate an interrupt when the counter wraps around.
Yeah I just use an irq for 32 bit hpet
omg
now i can test nyaux on my pc !!!
yes
anyways i think ill be good on saturday to work my arm and leg are feeling better
im taking off the plasters and like
the um
wounds look pretty bad
😭
if we are lucky maybe friday
however fast my body decides to heal
im still in pain sadly
@surreal path can you say what hpet you supported earlier
What did you do?
poor nyaux
something rlly bad
i took off most of the plasters
the wounds look worse then i thought
thought they were scrapes or smt
but they are like
ew
i dont even wanna describe it
its good tho we will do work after i sleep
i know how to fix the yk what
since in saturday
and its been nearly a week
I meant like how did you hurt yourself
It'll be alright 
fell off my scooter while traveling at a really fast speed
my bad
was sleeping
btw
i promise u monday i cannot do today or tmrw its my brothers birhtday and my dads not letting me use my laptop because im always on my laptop on the birthdays and hes mad abt that 
monday tho i SWEAR
no excuses
hold me accountable for monday, monday is where ill fix most things and get started on the vfs after fixing the issues with the kernel mutex
I understand why you were (are?) in pain then. You are lucky you didn't break anything
yea still in pain

im lucky yea
if i dont do monday ban me
:^)

32 bit and 64 bit
Your sleep schedule really is a mess. I've just woke up, and I'm 10 or 11 hours ahead of you (UTC+11)
yea
😭
even my gf is mad about it
You could fix it
The simplest way is just to stay up until a reasonable bed time tomorrow for you
The other option is to slowly improve it by going to bed later and later over time until you get to a normal time
You can
im good
who ping
bru
yo i have been debugging this for a while
things are weird
there is a bug where it dies on push into list??
like
i made sched yield actually have the threads registers before calling schedd
save*
like
the behavior is so weird
i couldnt figure it out
but ill keep trying to
well
not just that
usually it still dies
idk its weird
legit no idea whats going on
now its not even doing that anymore\
idk
this shit weird
;no

fix your sleep schedule 
no
wtf
this is one of the behaviors
its mostly consisent
no idea whats causing it tho
at all

yesss
how
HOW
i changed how i do scheduling
from putting it on the kstack to
putting the frame on the thread itself

:(((
global sched_yield
extern schedd
global load_ctx
global save_ctx
extern memcpy
save_ctx: ; (new frame in rdi, old frame in rsi)
test rsi, rsi
je .escape
mov rdx, 176
call memcpy
.escape:
ret
load_ctx:
mov rsp, rdi
add rsp, 8
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
pop rbp
add rsp, 8
iretq
sched_yield:
mov ax, ss
push ax
push rsp
pushf
lea rax, [rsp+8]
mov ax, cs
push ax
push rax
push rbp
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
push qword 0
; push gs ; Save previous state of segment registers
; push fs
mov rdi, rsp
call schedd
my code
I think you should also xor rbp,rbp
why
why not
bru
this is a struggle to debug im going to be straight honest
i need to proof read the code ig
for ze scheduler at least
no im awake
no
no im not giving up
never i will never EVER give up on nyaux
i just found out somethings up with the context switching itself
its going back to the same instruction
and repeating it
so our saving context is not working?
i believe this is where our issue lies
everyone is asleep
😭
memcpy is crazy
whats wrong with memcpy chat
nothing
just
an Interesting way to accomplish the task
that's exactly what a C compiler would do
bad way?
.
so no, not bad
but the magic numbers go crazy
or rather one magic number
i know what it is im js
kernel mutex and the context saving
or any other thread
its okay dw
hows nyaux
umm
well
struggling on a bug with context switching
specifally conterxt saving
to which im not finding out ze issue
im afraid
lmao
yea fair 😭
me either
how long have we been having this bug now
a day
ig
so i have to keep debugging
more

if my debug skills are gonna be improved i gotta do this for a few days
before asking for help
if i dont find it on friday or whatever ill ask for help
anyways
@finite summit wanna watch me live stream debugging nyaux?
in #voice-0
ahhhh fairrr
after cleaning up the receive code
goodnight man
lesgo
💀
no
that wasnt the issue
this is the issue
memcpy takes 3 parameters as yall know
dest src and cnt
i have put the new frame as the destination
which is fucking stupid
💀
☠️
@finite summit no way right
bru
u got this
thanks man
yield is broken it seems
wait no
thats not yield
uh whats going on
gdb time
i may need to do this no 1
because i am corrupting other functions stacks
i need to do a mov rbp, rsp
as c is treating me like a function
shit
i have no idea
how to make this work

because id be overwriteing rbp
overwriting
ummm
what
open windows terminal
i know
open ubuntu
right click ubuntu
fair
maybe im misunderstanding something
im unsure
yeah i like my text readable yk
yeah i think
why do you think
it's a problem
stack traces? or what
so what
as long as you leave the stack in the same state as it was before leaving
you are fine
why
you will eventually
return to where you yielded from
or maybe not
but in the case you will
yield has to return to the caller
okay
but
i dont think this is correct for getting the rip
plus im overwriting rax
which i somehow shouldnt so this makes it so difficult cause like how am i gonna do anything without any registers
i have an idea
hacky but it works
yes
fair enough
thats also wrong
this is still wrong

ima take a break for like a short while
cause my head isnt there right now
good to know we fixed one bug today
just one more we need to fix today
well two if i can somehow figure out kmutex
today
what ze fuck
then the ffffffff is here
wtf
thought i was gonna take a break btw
but
nah
ughhhhh
this is so hard to write
this is so hard
ughhhh
yea i need a break for a bit
cpu is trolling me i swear
what are you trying to do
why am I seeing you mess with segment registers
when
bro what
i need to push ze registers
was busy today
so didnt have time to check discord
bro
ok im gonna be straight honest
i need to fix my sleep schedule
like
i REALLY
need to fix it
i will attempt to sleep early and wake up 2pm
not feeling like i wanna work on nyaux rn
will see in a bit
dont feel amazing
fuck you im working on it
okay
im questioning if i have to save the old rsp val too

looks like i have to worry about this too
what are you trying to do
sched yield
im gonna throw myself out the window
for some reason the cpu isnt dereferencing rsp??
like BRO
and what you want this to do
yield
why you using lea ?
with []
if you want to get a value in rsp + 8
just move it to rax mov rax,[rsp+8]
or just push it push qword [rsp+8]
that solved that yes but
getting the old rsp value is giving me garbage
old rsp right
now its garbage
one question why you pushing these values
for what you need this
and how src looks
global sched_yield
extern schedd
global load_ctx
global save_ctx
extern memcpy
save_ctx: ; (old frame in rdi, new frame in rsi)
test rsi, rsi
je .escape
mov rdx, 176
jmp memcpy
.escape:
ret
load_ctx:
mov rsp, rdi
add rsp, 8
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
pop rbp
add rsp, 8
iretq
sched_yield:
push rsp ; old rsp val + 8
push rax ; + 8
push qword [rsp+16] ; + 8
mov ax, ss
push ax ; + 8
push qword [rsp + 24] ; + 8
pushf ; + 8
...
how sched_yield called
like is it called by interrupt
Are you a saxophone by chance?
no
yesn't
Are you calling sched_yield or jumping on it
everyone sayas that
calling from c
tenor or alto
makes sense
like if you call there is on stack new value
how tf did you know
how did I know what
idk do you play the sax?
makes sense
real
i was literally coltrane
@surreal path can you comment on what exactly you are pushing
wdym
im pushing a stackframe
my scheduler expects this
read function schedd
in src/sched/sched.c
what the fuck
[rsp + 24] you are getting on it as a result of push rsp
in 34 line
also this adds,subs is bad
all fixed now thanks to @thorn bramble 's help
@thorn bramble basically quantum physics in a nutshell
everytime you look it's all good
back to the kmutex bug we've been stuck on for nearly 2 weeks

i think it might be nyaux's best interest to move on from the kmutex bug and focus on other kernel things
yes kmutex doesnt work
yes we dont get schedule for work completion or any of the goodies therefore ec driver might shit on some hardware as @kind root said
but weve been on this for 2 weeks now
and kmutex isnt CRITICAL to the kernel
at least for the time being
yes even i feel shit about just leaving the kmutex bug
i will make a poll for this
it seems not to be an issue of the run queue
it seems to be
something else entirely
context switching maybe
and the behavior is differetn each time
after a while it seems it just doesnt wanna execute code
wtf is going on
save context is broken it seems
it would explain all the weird shit that was going on
it wasnt a bug with kmutex
lets pull out gdb
what ze fuck
why is rip zero
in the old frame
what
rsi is the ne frame
new*
and the old frame
is the stackframe
could it be an issue with sched yield
idfk
something really weird is going on
and then it doesnt even write it
like wtf
what
tf is it doing
oh
yea
makes sense
well ofc it would be
because
fucking
idk

That jmp followed by a ret concerns me
you calling it from C code...
you need to call it from assembly
a wait
- you don't need a memcpy in asm...
2.you jump to memcpy
it's bad idea
because you don't push RIP to return
so you need call memcpy
anyway do it in C
also I still have no idea why use an irq frame and iretq for context switch lol
iretq can change ss and cs
yeah but you don't need to do that in your sched switch
it can just switch between kernel mode threads
and then interrupts handle the actual returning to usermode
then what will be better than iretq ?
normal ret
and you only need to save callee saved regs to the stack inside sched switch in that case
how about rflags or can it be changed by other instructions ?
there are multiple ways to do scheduling ofc this is just one of them that I think works pretty well
yes if you need to save that for kernel threads you can pushfq popfq (though I can't think of any other reason than the interrupt enable state why you'd save it as all the condition flags etc the compiler assumes to not be preserved across function cal)
void timer_irq() {
eoi();
// switches to other thread
sched_switch();
// resumes here when this thread is resumed and does iretq to userspace from the irq stub that called this function
}
I have no clue what you're trying to do
Why
You're not supposed to do that
cause for context switch
yea but that causes issues
plus i was called
by c
so i should have the return address
so the ret should work
i changed how i did it
it just easier
it is not
you're doing something weird
how is it weird
like nah it isnt
its good
i js need to figure out why its shitting itself
🤷♂️
im still in ur walls tho
i must spend time with my gf
then i will work on nyuax
which 
I think different
bro is the rizzler
lol
mogging us fr
real
nah but this girl is actually kinda obsessed with me
so i think
the relationship will last
i hope anyway
lets not jinx it
but no nyaux is unironically good looking so its understandable
we can do a reverse correlation between OS working and gf
lol
real
yes
phd code = no maidens

I think you can actually make a correlation lol
it probably doesnt have meaning
but it is a fun coincidence
at the end of the spectrum you have like
astral, keyronex and mintia
I dont think matthew has a gf iirc
and will is gay
so
correlation != causation etc etc
@elder shoal 
no gf no working ps2 driver
outlier I can think of is managarm
no
get one
but i dont change gfs every week so who knows
ok im sure ur not THAT bad
at least ive been able to consistently have decent weight and exercise etc
yea u got what u need
just be a little more confident
when it comes to girls
and youll be good
who knows
my gf might not like if im being confident around other girls
wait u have a gf
lol
if 💀
yup
real
its funny because if u asked me id have to think how old i was for a second
u kinda forget after 20ish
its just not a number u think about
it started happening to me after i was 26 or so
i generally subtract current year from my birth year to confirm
ah i see
i suppose because 25 is sort of a milestone
I like guys and no I dont have a bf
i expect i'll remember my age better when i'm 30, then forget it even harder into my mid 30s
im 17 and I forget my age sometimes 💀
nah ur 17
nahhh
nahhh bros my age
ok so to have a working OS you gotta be gay
noted
chances are im younger than you
you're brazilian, i'm sure you'll not have much difficulty finding one
will is here 
I'm born in summer
yea im younger
he lives in my country so im double scared of that dude
bro could pull up to my house
uk?
so uk 
one can dream
north ireland or ireland
(I dont really have time, university and work take up too much already)
i already suggested it lmfao

😭
plagerism
become a mormon as well
just make sure you vote for fine gael as soon as you're 18 and you'll be grand
i've only heard people from ireland use the word grand
is fadanoid also irish..
like not even in this server
no
yeah
🏴
if so im double cooked
no but i'm from the highlands and we are originally an irish colony (dal riada) + i go on holiday to ireland on occasion
dont come to my house please
do you play golf
if I were scottish id play golf
no do come and teach nyaux some osdev theory
myself i don't but i have a few friends who do
I do play golf here but we get like a 4 months only when its playable
they have to because a few of them work at a golf club
and i'm 5 miles away from one of trump's controversial courses
turnberry?
balmedie
turnberry is apparently the most beautiful course in the world
i think trump decided to buy a bunch of courses in scotland because of his mother's lineage or something
https://www.youtube.com/watch?v=8m24yYMW2iw&start=10 balmedie is notorious because trump's goons and even his son trump jr tried to intimidate locals, harmed their water supply, knocked down some unique sand dunes
Crotchety Scotsman Michael Forbes regales Amy Hoggart with tales of antagonizing the Trump family tree.
this guy and his mother were victims of that
his mother's home is as far from his personality as you can imagine
I cannot say anything about this
the isle of lewis (also the namesake of part of managarm) is devoutly religious and not loud, obnoxious, or arrogant at all
That's something that a devoutly religious, loud, obnoxious, and arrogant island would tell people to say
burps
which part of managarm
I know I'm younger than you...
https://github.com/managarm/lewis this one
Lightweight SSA compiler suite. Contribute to managarm/lewis development by creating an account on GitHub.
huh didnt know that existed
is any member of the team scottish?
I thought they were all german/dutch/polish
it's in keeping with the norse theme
they ran out of deities?
the isle of lewis was part of the kingdom of the isles, a kingdom established by the vikings
I don't think I'll ever run out of deities with my greek theme 
and possibly the word is norse:
Derived from Scottish Gaelic Leòdhas, of uncertain origin; traditionally referred to Old Norse Ljóðahús, from ljóð (“song, poem”) + hús (“house”); but may be related to the Pictish name of the island recorded in Ptolemy's Geography as Λίμνου (Límnou).
it's not like I have more than 4 components with names
Yep. There are so many greek deities
I try to make it logical too (atlas being the "support" library, as he is the one who supports the skies)
you'd be in more trouble if you picked a monotheistic religion
the name nyx is mostly a wordplay on unix tho 
but i suppose you could use angels etc
yea or prophets
I mean templeOS had a naming scheme somewhat
the root of the filesystem was called Adam
azrael can be the reaper
i think the init process would be more fitting
(at my university)
there's a store called solaris here
i wonder if perhaps it's not a coincidence
is that a portuguese extinguisher?
Spanish
oh i see it now
bruh https://www.unix.es/
extintor de incendios or something like tyhat
I saw this in informatics faculty
i thought it said extintor de incendiao which sounds portuguese
amogus
i pissed of my gf today :)
off*
anyways
im gonna like
relax for a bit
before i go back to debugging hell
:^)
sigma
remember you always have duck
crazy
uhhh
give me like
an hour
idk
i cant stop watching undertale videos
and ksp videos too
average 17 year old experience
mhm
3:30am
yes
At 3:30am of course
did you eat 8 hours ago
dont think i feel like working on nyaux today
js a little exhausted
tmrw tho we debug
@surreal path do you fat or you are thick
then you need to become fat and your osdev will be better
bru
yea hi
i feel shit today as well
im sorry
but i need like to fix my sleep schedule
i cant live like this anymore
my dad said he will somehow fix it tmrw
by making me stay awake
if he suceeds on that ill work monday
otherwise ill force myself tmrw to work if i still have the shitty sleep schedule
its too difficult to work on anything like this
everyone is asleep
ur only awake
its dark and everything just feels depressing
i know u said yesterday id work tmrw
but please let me have this time to focus on just sleeping normally again
nyaux code quality will increase if i have better sleep
so there is a benefit to this
i didnt give up on nyaux if any of you are thinking that
i have a few ideas on how to debug the scheduler actually
even tho i want to work on it i just need to focus on sleeping normally
im sorry again
and i hope yall understand why im doing this
sorry about nyaux having really slow progress the last 3 weeks now
- you don't need gf
- your asm code in scheduler is terrible
Don't worry about it
Good, focus on yourself first ^^
It's alright 
bro
also
hi
my dad didnt wake me up
cringe
he said he was sleepy
himself
idk he said he ll do it monday
which is tmrw
thanks
thank you
okay lets work
okay
so the fact its doing different behavior makes me think we have a race condition of some kind
yea i dont think so?
i feel like i might be corrupting something
maybe our timer is not firing?
lets check if interrupts are disabled
no they are enabled
okay so
weird?
in gdb ive been seeing where it iretqs too
to
and it iretqs to each thread normally?
but its stuck because someone has the terminal lock?
it shouldnt hto
because theres no kprintf call in each function
interrupt handler
or the scheduler
this is fucking
weird

yea im absolutely unsure whos holding the kprintf lock
im still suspecting its a bug with the scheduler
idk i just feel like it

real
sorry
something happened
im back
back to debugging
still dont know whats going on


this emoji is should be the mascot of Nyaux
yes it should real
because i am having mega pain
debugging this weird ass issue
but now
im really sleepy
help

:nyaux:
because you're doing weird ass things
Have you considered asking a therapist/psychiatrist on how you could best try and get a decent sleeping schedule again
yes
nuh uh
wasnt any help
i was even prescribed new sleeping medication
which doesnt work
tell them it doesnt
your doctors/therapists cant help you if you dont talk to them about things like this
my next appointment isnt for another week
time to debug some more
if i cant figure this out today im gonna actually ask for help cause im sick of this issue 
i figured it out
the bug
so basically
the scheduler is not saving the context even tho i am
extern memcpy
save_ctx: ; (old frame in rdi, new frame in rsi)
test rsi, rsi
je .escape
mov rdx, 176
jmp memcpy
.escape:
ret
so what basically happens
they all want to do the first thing in the code
print something
so funny kprintf deadlock occurs because well
they want the print to the screen but oh no
im back at the start
of the function
@silver yarrow is jumping to memcpy bad
because i dont remember
but
i remember something about
idk
there was some bug that got solved with a jmp
im genuinely unsure why
could be switch queue maybe
i might just do it in c
since
its not actually having the context
okay ima try this
quite simple
nvm
the bug didnt solve itself
in fact
this is not how I would do this at all
push/pop
- push all registers on stack
- swap rsp
- pop all registers from stack
thats a context switch
kk will try
well no
because
load ctx does that
not push
but pop
i dont understand
what are you trying to say @silver yarrow
wdym load ctx
there is only switch
(in my impl)
I dont see a reason to have a save and load separately
that just overcomplicates things a ton
okay well
at least my impl relies on the fact that the switch happens at once
can i see ur impl
so i can understand what ur talking about
cause i dont get how save context is done
yeah, just its probably the worst to read part of my kernel
here is the assembly part
here is the arch specific C part https://git.thenest.dev/wux/elysium-os/-/blob/6.0/kernel/src/arch/x86_64/sched.c?ref_type=heads
ohhh ur impl is way different then mine
u dont store the frame inside the thread
u did it on the stack
yea what ur saying doesnt apply
i did it before but
it causes problems
so i switched to the simple approach
@silver yarrow
what ur doing is not simple
id argue just saving on the stack is actually far simpler
some people here aruge otherwise
who
hold on
i need to get their names
wasnt it u @thorn bramble
i cant remember
either way @silver yarrow i dont know whats going on with my bug
idek know whats going on in the first place
i thought it was that
but no
i dont know whats happening
something it works
sometime it doesnt
can I see ur context switch
yea
extern memcpy
save_ctx: ; (old frame in rdi, new frame in rsi)
test rsi, rsi
je .escape
mov rdx, 176
jmp memcpy
.escape:
ret
load_ctx:
mov rsp, rdi
add rsp, 8
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
pop rbp
add rsp, 8
iretq
im reusuing the stack frame for the interrupts
btw
what is test rsi, rsi supposed to do
