• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

A harder quiz for the HT forum

Uuplaku

Member
Ok kiddos, take this source code:

#include <stdio.h>

void MAIN()
{
printf("This is a messgage. Yay."/n);
}

Now, make it into a multithreaded program, and post the source code donw below. This may be excessive overkill, but I wanna see if anyone knows how to do multithreading code. If you can, you're a C god!
 
Uhhh... What the??? Multithread a printf statement? I think I just had a seizure... 😉

Forget software... HARDWARE is where all the Highly-Technical fun is. 😀
 


<< Sure thing, after you post a schematic for a 60Hz 115VAC -> 9VDC * 10A switching power supply. 😛 >>



Well, lets see. You take the 120v run it Through some caps for power smoothing, then through 4 diodes in a "certan" topography, then through some mosfets with a pot, then to power out, and you have a supper crappy powersupply 🙂

<edit>
"Message"
There I did it. You don't get source code tho 🙂
</edit>
 
i can do it in java.... never tried in C/C++.
anyway, if you want, i (or probably many people here) can post source for a program in various languages that has two threads, one wirting a's, the other writing b's, and the output will be someething like

aababbababbbbababababbaba....
 


<<

<< Sure thing, after you post a schematic for a 60Hz 115VAC -> 9VDC * 10A switching power supply. 😛 >>



Well, lets see. You take the 120v run it Through some caps for power smoothing, then through 4 diodes in a "certan" topography, then through some mosfets with a pot, then to power out, and you have a supper crappy powersupply 🙂
>>


hmm. i can drastically improve that WITHOUT making it more complex. use a transformer 😉. then you wont have a pot that explodes as soon as you power on because of the, oh.... few hundred watts it needs to disipate 😀
 


<<
#include <stdio.h>

void MAIN()
{
printf("This is a messgage. Yay."/n);
}

>>



An even harder question: Why can programmers not spell properly?

But you could multithread it by having 1 thread print the first letter and the second one print the second and so on.
 
In Unix/Linux, I would use p_threads.

#include <pthread.h>
#include <stdio.h>

void *thread2( void *arg){
printf("This is a message. Yay.\n");
}

void MAIN(){
pthread_t tid;
pthread_create(&tid, NULL, thread2, NULL);
printf("This is a message. Yay.\n");
}
 
Your quiz is platform dependant as shown by the person who posted UNIX code for this.

Carlo



<< Ok kiddos, take this source code:

#include <stdio.h>

void MAIN()
{
printf("This is a messgage. Yay."/n);
}

Now, make it into a multithreaded program, and post the source code donw below. This may be excessive overkill, but I wanna see if anyone knows how to do multithreading code. If you can, you're a C god!
>>

 
Back
Top