[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: 1737780691839246.jpg (222 KB, 2048x2048)
222 KB
222 KB JPG
previous: >>108252317

#define __NR_semget                64
#define __NR_semop 65
#define __NR_semctl 66

https://man7.org/linux/man-pages/man2/semget.2.html
https://man7.org/linux/man-pages/man2/semop.2.html
https://man7.org/linux/man-pages/man2/semctl.2.html

tl;dr:
semaphores, but worse!
https://man7.org/linux/man-pages/man7/sem_overview.7.html
to be clear, these syscalls are NOT posix semaphores. but the above link mentions them in the notes, and it should explain a bit more

i try to avoid any multi-threading primitives outside of the basic mutex and condition variable. i know that the others have their places, and there are definitely circumstances where they're far better suited to the task at hand, but they're also way less widely known and used. if you stick to just mutexes and cvs, it's a lot easier for anyone coming after you to read your code and know what the hell is going on.
what about you, anon? what's been your experience with multi-threading primitives? have you ever used semaphores before? if so, why?
bonus: https://en.wikipedia.org/wiki/Semaphore
are you familiar with where the term semaphore came from? most people are, but in case you aren't, give this article a read. it's pretty interesting

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/
>>
>are you familiar with where the term semaphore came from? most people are, but in case you aren't, give this article a read. it's pretty interesting
I only knew that semaphore was traffic light in Czech/Slovak, so I was familiar with the term before I knew about semaphores in computers, but I didn't know its actual origin.

>what about you, anon? what's been your experience with multi-threading primitives? have you ever used semaphores before? if so, why?
I read about them on the Osdev wiki when I was browsing through it, but I never got far enough with my hobby OS that they would have been of any use though. I never programmed anything with semaphores, and I doubt I will any time soon.

Also putting questions in the OP makes it easier to know what to respond with, so it's easier to have a conversation like this.
>>
>>108262843
i'm gonna fuck your ass
>>
File: 1767852603238574.png (236 KB, 736x820)
236 KB
236 KB PNG
>>108263011
i'm mostly sex negative, i think
>>
>what about you, anon? what's been your experience with multi-threading primitives? have you ever used semaphores before? if so, why?
I used semaphores when implementing blocking in a multiple-producer multiple-consumer queue. If a thread tries to pop an entry out of an empty queue, it runs sem_wait, and when a thread adds something to a queue, it checks to see if any threads are blocked on it, and then runs sem_post to wake them up. Those were posix semaphores though.
Nowadays I'd probably just use a futex instead, but it worked fine.
>>
>you stick to just mutexes and cvs, it's a lot easier for anyone coming after you to read your code and know what the hell is going on.
As far as I understand it, the point of these semaphore apis isn't necessarily for thread synchronization but process synchronization.
So why does the OS only provide syscalls for semaphore, but not for mutex? You can trivially implement mutex in terms of semaphore operations, but I guess the other way around isn't as straightforward? I haven't really played this out my head.
>>
she semgets me if you know what i mean
>>
>>108263556
it does provide syscalls for mutexes
>>
bampu
>>
>>108263045
idc
>>
mob face sexo
>>
>>108265526
l-lewd....
>>108265536
you too honestly
>>
semop is pomes backward
have you ever written a pome, OP
>>
>>108266486
>a fruit consisting of a fleshy enlarged receptacle and a tough central core containing the seeds, e.g., an apple or pear
a fleshy enlarged receptacle......
i wrote poems as an angsty teen, yes
>>
bampu 2
>>
why does glibc mimic a lot of kernel syscalls? do they think they can do it better or is it a comparability question?
>>
>>108267576
it (generally) doesn't mimic them, but just wraps them
>>
>>108262843
>what's been your experience with multi-threading primitives?
linux futexes are pretty good
>>
>>108262843
I wish I can draw like this.
>>
>>108268097
just download stablediffusion



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