your video is 4 years old but I really appreciate your help
@cesaltinofelix7 сағат бұрын
i was here
@georgesaman69223 сағат бұрын
Incredible. I've learned so much from you! appreciate all your efforts!
@Anduuu077Күн бұрын
very good video adn explanation
@sidahmed2.0442 күн бұрын
Based guy
@khomo122 күн бұрын
Nice! Thank you!
@engmoatazabdelhalim73432 күн бұрын
Thanks a lot
@drdriven3 күн бұрын
literal saviour
@bunnysupreme743 күн бұрын
When you used wnohang, the parent process finished before the child processes. But wouldnt that cause zombie processes, since the parent process is responsible for terminating its child processes?
@nadiatavarez84544 күн бұрын
I have never seen someone explain programming this good! Nice work! If there is ever a chance u do videos for c++, please do!
@ismbks4 күн бұрын
legit everyone at my school recommends to watch this series, crazy work
@Varelinski5 күн бұрын
1:13 I didn't even know you could initialize struct values like that...
@ic_12346 күн бұрын
thanks man!!
@stack.16 күн бұрын
For accessing variables accross threads shouldn't that be limited to stuff created on heap?
@stack.16 күн бұрын
I think if you're using Cmake the dependent libraries options are automatically set for compile/link
@cesaltinofelix7 күн бұрын
i was here
@散华-l9m7 күн бұрын
19:31 thread works only when it gets a task, otherwise wait and release lock
@AlfadelAbdAlla-y8g8 күн бұрын
CAN YOU DO A VIDEO FOR POINTERS
@散华-l9m8 күн бұрын
mutex here to protect the shared memory (Task queue) 14:36
@散华-l9m8 күн бұрын
also make sure 13:21 each thread would not executeTask when they have no task! (found ==1)
@散华-l9m8 күн бұрын
okok after one thread got the task, the release the lock for other threads to get the tasks. But at the same time, we want every tasks immediately execute after they got the task. So execute Task should be available at any time. (even if 2 or more thread got their tasks.)
@AmirMohammadCheshmBerah8 күн бұрын
in first method actually we using deque you can't iterate queue backward
@KH-en1yr10 күн бұрын
did you make a separate playlist/course of such functions? if so, please let me know its name.
@naboulsikhalid776310 күн бұрын
thank you for making it simple to graspe.
@MrSomethingdark12 күн бұрын
Hey CodeVault, thank you for giving me back my sanity. You and portfolio courses and so many lucid people online really serve as a nice place to refresh my mind after taking an online course for a certificate. Thanks a lot. I need this tutorial. Stay frosty!
@AdeBorris12 күн бұрын
Great analysis, thank you! I have a quick question: I have a SafePal wallet with USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). Could you explain how to move them to Binance?
@nandorboda804912 күн бұрын
7:15 It's important to notice that bytes are in reveresed order at each element. It's called small endian. For example if there wouldn't be small endian arrangement, the first element, 16, should be represented as { 00 00 00 00 00 00 00 10 }. Firstly it's not very noticeable in the case if you used 16,31,32,65 or other numbers that can be represented as a byte but if you exceed that byte, the small endian arrangement will be noticable. Ex. (unsigned) 256 would be { 01 00 } but with small endian representation it's { 00 01 }. So this program is only good for these small numbers.
@clarencelucius908513 күн бұрын
So it's a pointer to a pointer?
@DmitryMyasnikov13 күн бұрын
Thanks!
@Stoh14 күн бұрын
Phenomenal video, thank you.
@Kingdomprogrammer14 күн бұрын
I made a nice improvements to this code. maybe wanna have a look? I set a max size of the car's fuel tank and made sure the fuel tank was full before the car leaves the filling station and also made the the filling station only signal the car only when there's enough for the car(i.e fuel > 40) at least to help improve understanding
@Kingdomprogrammer14 күн бұрын
in the fuel filling function, if you don't sleep after a single loop, it completes all 5 iterations before it signals the car routine thread. why's that so?? the signal is in the for loop. and since the code executes for each iterations.
@stack.115 күн бұрын
@stack.115 күн бұрын
so we can do execlp("bash", "bash", "-c", "ping ....") ; ?
@stack.115 күн бұрын
ok yeah we can
@KH-en1yr15 күн бұрын
what if we don't know the count?
@CodeVault13 күн бұрын
You can also pass a special value (usually NULL) at the end to signify the end of the arguments
@ree-10115 күн бұрын
brilliant explanation. not only did you explain how to use it, but also what happens to the code in the background as well. thank you so much
@n_stre15 күн бұрын
Thanks Sergiu! Would love to see your take on arena allocators in C
@CodeVault15 күн бұрын
I haven't implemented one but I did start reading on it. Honestly it seems like a better idea than allocating/reallocating/deallocating every little thing in the project. So many optimizations could be done this way
@MertUnaldStudent16 күн бұрын
hello , why in this case the child process doesn't have 0 as process id ? . Thank you
@CodeVault15 күн бұрын
The child process never has id 0. What was 0 was the return value of fork() which doesn't represent the process id in the child process. fork() returns 0 in the child process and the child's process id in the parent process.
@rajivkumarkale16 күн бұрын
Race conditions can occur in both single-core and multi-core systems, though they are more common and likely to cause issues in multi-core systems. Here’s why: Definition of a Race Condition: A race condition happens when multiple threads or processes access shared data or resources at the same time, and the outcome depends on the order or timing of their execution. Without proper synchronization, these concurrent accesses can lead to unpredictable and incorrect behavior. Multi-Core Processors: In multi-core systems, different cores can execute threads or processes truly in parallel. This means that if two threads are accessing the same variable, one thread may read the value before the other has completed its write operation, leading to inconsistent results. The parallel nature of multi-core systems amplifies the risk of race conditions, especially if synchronization mechanisms (like locks or semaphores) are not used. Single-Core Processors: Although single-core processors execute threads in a time-sliced manner rather than truly in parallel, race conditions can still occur here. This is because the operating system can switch between threads at any time, interrupting one thread in the middle of an operation and allowing another to execute. If this interrupted thread was working on shared data, a race condition can still result, despite the lack of true parallel execution. In short, race conditions are possible in both single-core and multi-core systems, but multi-core systems make race conditions more apparent and challenging to avoid due to true concurrent execution.
@CodeVault15 күн бұрын
That's exactly right! I misspoked when I said that they can't happen on single-core systems. Sorry about that
@zikocult16 күн бұрын
if i don't want to declare x as global, how can i pass the value of x to the function? when i try this "sa.sa_handler = &handle_sigusr1(x);", give me an error. The prototype of my function was void "handle_sigusr1(int x);"
@CodeVault15 күн бұрын
Since the handler is called on signal there isn't an easy way to do it without relying on something that is global
@zikocult15 күн бұрын
@@CodeVault Thanks :)
@gabriela-80717 күн бұрын
I understood what you meant, but I didn't understand how each thread sees the correct index just because it allocated a space in memory. Doesn't each thread, when it starts and enters the function, run the risk of accessing the same index? Why didn't you use the mutex in this case? Excuse my English, I'm using the translator
@CodeVault15 күн бұрын
Not really, each thread gets created with a different input index therefore there is not issue accessing the same index. Actually, in this case it wouldn't even matter since we are only reading the values. Parallel reading of data is fine, only when writing do race conditions become a problem
@添野祥子17 күн бұрын
ありがとうございます!
@CodeVault15 күн бұрын
ご寄付ありがとうございます!
@DragonDreamer-b9o17 күн бұрын
amazing, I cant find any other platform that breaks it down like this to help me understand, thank you!
@christiansaab204419 күн бұрын
bro just saved me litteraly 16 hours of lab sessions in around 5 videos
@yoram969219 күн бұрын
Awesome video bro you are bright
@HimanshuSharma-b3q3u19 күн бұрын
hey @CodeVault , your linked site is not working anymore. is it only for me, or its offline in general?
@CodeVault15 күн бұрын
It wasn't working for a bit. Now it should. Although, it's weirdly developed and needs access to store data to LocalStorage, make sure you try other browsers as well. Some come with that disabled
@elevatordude808519 күн бұрын
thank you sir
@AbdelrahmanAzmi20 күн бұрын
your video is awesome bro, thank you so much!
@telwen156620 күн бұрын
Thanks ^^
@xinwu542720 күн бұрын
There is still an infinite loop in `startThread`, which never returns. Any solutions for this?
@CodeVault20 күн бұрын
You can listen to a signal or, on a different thread, have a scanf that, when entering an option, closes the whole process
@xinwu542720 күн бұрын
@@CodeVault thanks! Below `submitTask_done` is used to signal that all tasks have been submitted. Then, if `taskCount` equals 0 in the infinite loop in `startThread`, it will return NULL. ``` --- Thread_Pools_with_function_pointers_in_C.c 2024-11-02 15:33:30.508724954 +0100 +++ newer_version.c 2024-11-02 15:37:35.525364984 +0100 @@ -14,6 +14,7 @@ Task taskQueue[256]; int taskCount = 0; +int submitTask_done = 0; pthread_mutex_t mutexQueue; pthread_cond_t condQueue; @@ -51,6 +52,10 @@ pthread_mutex_lock(&mutexQueue); while (taskCount == 0) { + if (submitTask_done) { + pthread_mutex_unlock(&mutexQueue); + return NULL; + } pthread_cond_wait(&condQueue, &mutexQueue); } @@ -85,6 +90,7 @@ }; submitTask(t); } + submitTask_done = 1; for (i = 0; i < THREAD_NUM; i++) { if (pthread_join(th[i], NULL) != 0) { ```