[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1711842906061480.png (396 KB, 720x701)
396 KB
396 KB PNG
previous: >>108066842

#define __NR_nanosleep            35
#define __NR_clock_nanosleep 230

https://man7.org/linux/man-pages/man2/nanosleep.2.html
https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html
https://man7.org/linux/man-pages/man3/timespec.3type.html

i actually have a personal vendetta against this syscall (nanosleep). previously, i have played around with writing syscalls in pure assembly. for whatever reason, i could not get this one to work. i don't know if i am just retarded or what, but it seemed like no matter what i did, i couldn't get it to accept my arguments and sleep... or actually, maybe it was clock_nanosleep. i don't remember. either way, couldn't get it to work. which is unfortunate, because the api really isn't all that complicated. if anyone else can get it to work (and actually execute correctly), i would be really interested to see it. i can't imagine what i was doing wrong...
aside from that, great syscalls! use them all the time. i'm a fan of the classic sleep-assisted printf debugging, although these days i generally try to raise(SIGSTOP) instead. but the sleeps are nice for when it's multi-threaded stuff

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
nanodesu
>>
>>108075578
>sleep-assisted printf debugging
wth?
care to expand on that?
>>
I love autistic stuff like this. I love standards.
>>
>I just slept 5 nanoseconds as you wanted
>>
>>108075720
what part don't you understand?
>>
>>108076939
lol no i put it at like a really huge number
maybe i was off by a factor of 1000 or something though
>>
>>108077163
all of fucking it
i googled this shit and i refuse to believe you dont know that if you fprinf to stderr your printf is then unbuffered

so i asked you
dont act hoighty toighty with me autismo trash
i asked you a fucking question, politely
be polite in return
>>
>>108075720
people who refuse to use debuggers and inspect their variables.
also very quick sleepsort implementation to troll algorithm coomers.
>>
wtf is sleep-assisted printf debugging? why would you need to sleep?
>>
>>108077364
>people who refuse to use debuggers and inspect their variables.
im in that category, because why even learn a whole other framework, if (f)printf can provide exactly the same

its just that i refuse that an anon who's all about fukken syscalls doesnt know that stderr is unbuffered
its like- someone tells, and SHOWS you they can run
but they cant fucking walk?
how?
i must be missing something- thats my logic
so i asked my question
>no, the autismo rabble has to be passive aggressive
and im not passive aggressive because im not a faggot
when people start raising hands, i pull out the gat and spray everyone including the passer-bys because i have poor sight
>>
>>108077220
>>108077379
i even said in the OP lol. it's good for multi-threaded stuff. or for example if i want to ll /proc/<pid>/fd/ or /proc/<pid>/task/, or cat /proc/<pid>/maps. that sort of thing. but also like i mentioned in the OP, i usually just raise SIGSTOP these days so i don't have to rush as much
the printf isn't necessarily the critical part here. maybe that's what was causing some of the confusion?
>>
>coding thread on nocoder board
>filled with posts by retarded nocoders
roflmao
in Rust this is just
std::thread::sleep(std::time::Duration::from_nanos_u128(1001))
>>
>>108077421
fucking 4 hours, anon
you make a thread and then orphan it for 4 hours?
what the fuck

you know what?
ima get some kush
now YOU wait

until then youre a faggot
>>
>>108075578
Maybe the ABI for time values is quite fucked because Y38K required extending time values from 32 to 64 bits.
>>
>>108077460
Wow so simple!
>>
>>108077506
i have shit to do generally :<
>>
>>108075578
I don't ever write asm but this is all I got lol
```
.text
.global _start

_start:
pushq $500000000
pushq $1

mov %rsp, %rdi
mov $35, %eax # syscall SYS_nanosleep
syscall
```
it sleeps but it segfaults lmao and I can't spend much more time on it today.
>>
>>108077803
sorry for being harsh then
but still, 4 hours is quite exaggerated

its impolite in a good measure
aka- not nice. not nice at all

on the other hand
youre sure you didnt use usleep to just force switching contexts?
because i did something of the sort, and thats inelegant as fuck
its literally rude to the os because you have other tools at your disposal, and youre forcing it to follow a time based pattern as opposed to a process based pattern.
afaik.

also also:
arent signals slow?
i didnt benchmark them
but maybe you did...
even though sigstop does seem like a canonical solution...
its literally in the name, youre using it exactly for the usecase thats written on the tin
>>
>>108075578
gamedev here
i use this syscall exclusively for all thread sleeping since it supports such a wide range of time with exreme resolution
that being said timespec_t is not intuitive and i write in C not ASM
>>
>>108078418
>timespec_t is not intuitive
wrong
>>
>>108078248
I like these threads and would be sad if they stopped showing up before dinner time because OP is too busy to promptly answer questions
This part of the 4chins etiquette is not known to me
>>
>no caps
>unnecesary cursing
>WhAT abOuT PolItneSs
What a cunt.
>>
bampu
>>
>>108078229
>but it segfaults
you need to exit from _start
>>
>>108079100
should've clocked in from the second message
>>
>>108078229
oh, i was trying to do mine without the stack
>>
>>108081743
or you can just let your program segfault to finish. who needs clean exits anyway



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.