[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

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1729203942585485.png (374 KB, 931x708)
374 KB
374 KB PNG
previous: >>107974077

#define __NR_sched_yield        24

https://man7.org/linux/man-pages/man2/sched_yield.2.html
https://man7.org/linux/man-pages/man7/sched.7.html

oh wow, i didn't know about this one. i guess it's probably not a particularly surprising syscall, though, so that's kind of on me. definitely the sort of thing that's useful where it's useful, and kind of pointless everywhere else
what sort of scheduling policy do you like? have you ever had to implement one on your own (e.g., in an operating systems course back in college)?

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/
>>
>>107983688
Thank you for making these threads, it's a shame I can't contribute
>e.g., in an operating systems course back in college
Unfortunately not, the college I attended had purely theoretical classes on operating systems and thus nobody ever got to take a look at, say, Minix, which should be obligatory since it runs on basically every Intel processor in the world right now and its license is quite permissive
>>
>>107983688
>and kind of pointless everywhere else
not only pointless, on busy systems it degrades performance too
>>
op here, i'm trans btw
>>
File: 1769343232551141.jpg (44 KB, 472x482)
44 KB
44 KB JPG
>>107985142
you're not me, but you're also not wrong
we already had this discussion though
unless you're someone else posting the same message i guess. probably more likely, actually
>>
>>107985025
>on busy systems it degrades performance too
how so?
>>
>>107985869
>>
>>107985142
>>107985869
>anyone who learns their system is labeled a tinkertranny in neo /g/
>the board troon is basically the only poster making threads that don't suck donkey dick and nobody engages with them
most bizarre hyperstition i've seen
>>
>>107983688
thats not for schedulers (you cant implement your own userspace scheduler until recently)
thats for implementing your own threads/mutexes/condvars/sleep
>>
>>107987143
oh, yeah, i know. the two are just related (the sched man page for example references the sched_yield call), so i figured it'd be cool to have discussion of both of them ITT
i guess could could sort of implement your own per-thread scheduler, though, if you really wanted. or at least something that would emulate the behavior
>>
>>107986501
switching between processes incurs a decent amount of overhead.
all registers need to be replaced (multiple times, cos the probably kernel needs to run for a bit)
cache will probably get invalidated
the entire instruction pipeline gets discarded etc.

Imagine you're doing some calculations with pen and paper, and are frequently interrupted by... some other task that needs immediate doing.
Your performance in both will be worse than if you just did them one after another
>>
>>107983688
I'd be lying if I said I'dve paid this syscall any more mind than spotting its name and lack of arguments from syscall listings, thinking "huh, I think I get it", and moving on, lmao.
>>
>>107987513
oh, well, yes. that's to be expected from any context switching, though. i thought you meant this one was particularly bad for some reason
>>
>>107987545
oh, I'm NTA. but considering that the manpage mentions only context switched and makes no other special note, I'd wager that's it.
>>
>>107983688
You should basically never use this syscall. If you need your thread to wait on a condition, you should use something that actually talks to the kernel like a futex.
https://www.realworldtech.com/forum/?threadid=189711&curpostid=189723
>do not use spinlocks in user space, unless you actually know what you're doing. And be aware that the likelihood that you know what you are doing is basically nil. - Linus Torvalds
>>
File: 1755217221676811.gif (1.1 MB, 246x230)
1.1 MB
1.1 MB GIF
>>107985869
wtf I love trannys now
>>
>>107987513
>switching between processes incurs a decent amount of overhead
It's not only that. sched_yield() yields control indefinitely; it may return immediately or 1 minute later. If you're an idiot like me and think sched_yield() can be used instead of busy waiting, it can't
>>
>>107990869
i mean, wouldn't that apply with any preemption?
>>
>>107990956
Nah, you can experience abnormally long pauses with sched_yield() on your personal computer doing normal things much more often than any other way. This is based on anecdata though, I don't know what exactly the underlying code does
>>
>>107990956
different causes of preempt assign a different resume priority to tasks. as stated by the man page sched_yield() puts it at the "back of the queue" (it is considered to be of lower priority than e.g. a task that wants to resume via futex wake). so sched_yield() is more likely to result in longer wait times
>>
>>107987143
i imagine this syscall would have been completely btfo'd by addition of futex? having trouble imagining a scenario where user would realistically need sched_yield()
>>
>>107991799
Why tranny-case though? It's "I" not "i"
>>
>>107992074
It's actually ı



[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.