🇷🇺 Ryan
yeah when someone says kernel it means OS ...... but what about if someone is not using any OS just raw hardware? then they must have to write or include their own scheduler??
🇷🇺 Ryan
i mean all C++ becomes x86 assembly eventually
Vlad
on "raw" hardware you will not have threads either
🇷🇺 Ryan
ohhhh
🇷🇺 Ryan
interesting
Vlad
I have no idea how threading is setup on multicore systems tbh
🇷🇺 Ryan
then you are like me. still learning :D
Vlad
I know a basic bootloader just exists somewhere at a fixed address and loads stuff into ram
🇷🇺 Ryan
RAM you mean. ROMs cannot be loaded into... except EEPROMs
Vlad
Some work probably has to be done to "awaken" second cpu
🇷🇺 Ryan
my ignorance is very forgiving
Vlad
my ignorance is very forgiving
Not gonna destroy me just yet?
Vlad
🙏
🇷🇺 Ryan
hahahahaha i cannot destroy a single person in here. you are all my teachers in some way.
🇷🇺 Ryan
Let’s make this easier with an illustration. This is just based on my understanding of async programming in other languages. Suppose we have 8 OS threads prepared to run coroutines, and we create 50 coroutines (representing 50 request connections). The mapping here is m:n, meaning 8 OS threads will execute 50 coroutines. Now, imagine 8 requests come into our server: 1. We spawn 8 coroutines. 2. Our 8 OS threads pick them up and execute them. 3. One of the requests makes a Postgres query. 4. The query code runs → we pause that coroutine → the OS thread is now free and can pick up another coroutine (because the thread is not blocked). 5. After some time, the query result is ready. 6. One of the OS threads resumes the paused coroutine and continues execution until it’s done. So far, everything looks good. But what if one of the requests involves 8 minutes of heavy computation inside its handler? Here’s what happens : A new connection arrives → wrapped in a coroutine → an OS thread picks it up. This coroutine contains pure CPU-bound work. Unlike IO tasks, CPU tasks should not be paused. IO can run in the background while the OS takes care of it, but CPU computation requires an OS thread to keep running continuously. If we try to pause this coroutine, we’re also pausing the computation itself. So: If the computation takes 8 minutes, but we pause it for 1 minute → the total latency becomes 8 + 1 = 9 minutes. Pausing/resuming repeatedly just makes it slower and adds pointless delays. Now, let’s improve this by moving long running CPU tasks to a separate dedicated thread pool: A new connection arrives → wrapped in a coroutine → one of our 8 OS threads picks it up. The coroutine sees a long CPU task → instead of blocking, it delegates the work to the dedicated thread pool: > “Hey bro, give me one OS thread from your pool to handle this heavy task. I’ll go back to serving new requests.” The dedicated thread pool runs the heavy computation until it finishes, then returns the result to the user. Meanwhile, the connection handler thread has already moved on to accept and execute other coroutines. If a coroutine needs to wait for IO → it pauses. If a coroutine needs heavy CPU work → it gets delegated to the dedicated pool. This way: No request handler thread is ever blocked. No CPU computation task is paused (which would only delay results). Request handling remains fast and responsive, because the handler threads are always free to accept new work. IO tasks → can be paused safely, no problem. Long CPU tasks → should not be paused. Instead, offload them to a dedicated thread pool so request handling stays smooth. (And true paralel)
is this implying what is called a RACE CONDITION???? :)
~
And we don't do cloud because it is overpriced crappy service
Here most does cloud because they can not setup and maintain their own home server :( but they use resource efficient language like Go and Rust, although some uses Java and C#
~
He wants to believe that OS thread is forever blocked by the high CPU operation until it releases
So sir, I am aware of CPU context switch :v just to make the conn acceptor keep smootj although it is unnecerery because context switch will move the thread :)
~
is this implying what is called a RACE CONDITION???? :)
Which one is the race condition? 😅 because in my understanding, only 1 thread accessing it at a time
🇷🇺 Ryan
I do not understand what you are talking tbh 😅
<—- hardware guy. Application Specific Integrated Circuit, and, System-On-a-Chip
Mayur.s.k
@admin
Rose
Reported Mr.​ M [5276797583] to admins.​​​​​​​​​
Faathin
Hey guys, I made a helper library wrapper for Linux NTSYNC. It provides Windows Events and Semaphores and almost 100% compatible except it has no support for named events, semaphores, and APC. Suggestion and feedbacks are welcome! https://gitlab.com/kawaiighost/libntsync/
Amara
Anyone from india starting coding now
Manju
Anyone from india starting coding now
Me (༎ຶ⁠‿⁠༎ຶ)
Manju
Honestly its tough i want to cry ....
Manju
The more i study the more i need to go deep and it gets deeper and deeper
Pavel
The more i study the more i need to go deep and it gets deeper and deeper
Yeah, at least with C++ it goes like this for years. The more you learn, the more you find thangs that you don't know
Captain
Sorry this ot but Does anyone have the python grp link?
Captain
You use python
Yeah by importing c++ libraries
Lucifer
SQl
Rose
Another one bites the dust...! Banned Harsh. Reason: pm ad
onz
i gotta turn c++ source to pure C. Therse stl, std in it..
Anish
Hey, my college have an option to either learn C or learn CPP, what should I learn?....can you please tell that with reason
Pavel
Hey, my college have an option to either learn C or learn CPP, what should I learn?....can you please tell that with reason
Either one or another? Personally, I would go with C++, you will learn it eventually anyway, and it is more complex, so more stuff to learn. But I'm biased, I never learned C myself.
onz
export?
no, cpp to pure c. Like objects to structs, vector strings to normal strings etc.
onz
converting source code
Ziky
no, cpp to pure c. Like objects to structs, vector strings to normal strings etc.
Old tasking compiler had c++ implemented literary in preprocessor :D I was pretty surprised when I tried to use preprocessor to expand macros and includes and I got C code instead of c++ :D
Yanka Vasileva
Greetings
🇷🇺 Ryan
Hey, my college have an option to either learn C or learn CPP, what should I learn?....can you please tell that with reason
WANNA PROGRAM simple and safe code, or DRIVERS FOR HARDWARE? TAKE C ONLY FOR NOW WANNA DEVELOP GUI OR BACKEND APPS that need complexity? C++ easy. business apps or games? C#
Hades
Hey, my college have an option to either learn C or learn CPP, what should I learn?....can you please tell that with reason
C from learning pov, C++ has great standard libraries for abstraction (which is not good for learning, also its add complexity)
Antonio
I have a project to do in c. Can someone help me with it I can pay
Ziky
i also think about it. is there any you can recommend? or smth like c++ to IL to C
It was 8yrs ago and AFAIK tasking is automotive certified expensive garbage...
Antonio
wolf
when the c++ going to be destroyed by Rust?
~
when the c++ going to be destroyed by Rust?
It does not need to replace or be replaced, because they can actually work together. C++ can handle the really low level stuff, while Rust takes care of the business logic or higher level parts
SHEIKH HAFIJUL ALI
when the c++ going to be destroyed by Rust?
First question that should be asked is, why it needs to replace?
wolf
eg .DLL lib can't be changed without the help of 3rd package
wolf
in the runtime
wolf
I just start my c++ zero to hero journey,and I already get angry by many many things.One day I'll bring up a video to talk about this.
Pavel
First question that should be asked is, why it needs to replace?
Not soon 1. Rust sucks for many things, like game development, when you need fast code but also to iterate and discard fast. Rust is slower for development, and it takes even more time to make it fast (and at that point you probably have a few unsafe blocks and some unsound code there as well) 2. There is a lot of legacy code written in C++ that nobody will update while it works (why would they)
SHEIKH HAFIJUL ALI
I work with embedded netwoking system (switches and routers); nobody bothers to change even a line of working code
Pavel
I work with embedded netwoking system (switches and routers); nobody bothers to change even a line of working code
Every change has a chance to introduce new bugs associated with it, and the more used the system (or the bigger the amount of money that depends on it working), the more scary it is. And changing to Rust wouldn't give any benefit to most of the systems anyway.
~
Not soon 1. Rust sucks for many things, like game development, when you need fast code but also to iterate and discard fast. Rust is slower for development, and it takes even more time to make it fast (and at that point you probably have a few unsafe blocks and some unsound code there as well) 2. There is a lot of legacy code written in C++ that nobody will update while it works (why would they)
I think saying “many things” is a bit over the top. For me, it really depends on the use case and how skilled the team is right now. I also think Rust isn’t the best fit for game programming, C++ has Unreal Engine with decades of development behind it. From my own experience on an Intel i5 10th gen with 20GB RAM, compiling Rust and C++ projects that use third party libraries takes about the same amount of time. I’ve used Tokio, Libcoro, and Photonlib, and honestly the compile times felt pretty similar. Where Rust really shines, in my experience, is on the server side things like backends, game servers, and real time servers. The ecosystem there is already mature, and the documentation is easy to find and understand since it’s centralized on one site. By contrast, C++ library documentation can be scattered and sometimes hard to digest. I came from Go, and found that Rust is easier to master and produce high quality code (no memory mistakes, race conditions in safe Rust and less sneaky performance pitfalls). I have built some backends in C++, it ran, but when I benchmarked it, the performance was actually below Go and Java (it is “my C++ skill issue ><”). But in working with raw pointers in Rust feels almost the same as in C++ (the other safeties are still on, only raw pointer is same like in C++). That’s why I see C++ as great for the super low level parts, while Rust fits better a bit higher up the stack especially if the team doesn’t have super deep low level expertise. I use translation :)
Ludovic 'Archivist'
I think saying “many things” is a bit over the top. For me, it really depends on the use case and how skilled the team is right now. I also think Rust isn’t the best fit for game programming, C++ has Unreal Engine with decades of development behind it. From my own experience on an Intel i5 10th gen with 20GB RAM, compiling Rust and C++ projects that use third party libraries takes about the same amount of time. I’ve used Tokio, Libcoro, and Photonlib, and honestly the compile times felt pretty similar. Where Rust really shines, in my experience, is on the server side things like backends, game servers, and real time servers. The ecosystem there is already mature, and the documentation is easy to find and understand since it’s centralized on one site. By contrast, C++ library documentation can be scattered and sometimes hard to digest. I came from Go, and found that Rust is easier to master and produce high quality code (no memory mistakes, race conditions in safe Rust and less sneaky performance pitfalls). I have built some backends in C++, it ran, but when I benchmarked it, the performance was actually below Go and Java (it is “my C++ skill issue ><”). But in working with raw pointers in Rust feels almost the same as in C++ (the other safeties are still on, only raw pointer is same like in C++). That’s why I see C++ as great for the super low level parts, while Rust fits better a bit higher up the stack especially if the team doesn’t have super deep low level expertise. I use translation :)
> no [...] race conditions I have found plenty of race conditions in Rust code. The "fearless concurrency" crowd writes very shitty concurrent code and trusts the pretty basic concurrency protections of Rust way too much
Ludovic 'Archivist'
I have found much less race conditions in Go code actually
布丁
ymmv but in terms of overall experience Rust delivers higher quality code especially with concurrency
布丁
ymmv but in terms of overall experience Rust delivers higher quality code especially with concurrency
Go doesn't really prevent data races from corner cases to happen even with their race detector. The mutexes with defer pattern is also error prone
Ludovic 'Archivist'
I am sure that is deadlock sir, not race condition. Because the compiler would stop if a non Send and Sync object were sent to another thread.
I have found both, I found deadlocks, livelocks , inconsistent state handling, timing errors and more. memory collisions are the easiest race conditions to avoid, even in C++. In c++ it is a matter of shared_ptr<const T>
布丁
That's why C++ still sucks
Ludovic 'Archivist'
Spewing that Rust fixes race conditions altogether is the same rhetoric I was served with Java 15 years ago, and yet race conditions still slipped through and caused outages
Ludovic 'Archivist'
We still have TCP half-open like 10 years after the Zookeeper shitstorm
Ludovic 'Archivist'
TCP is OS managed no?
Like many other things indeed, and the OS will have a blast introducing race conditions to your "safe" rust code
Ludovic 'Archivist'