A harder quiz for the HT forum

Uuplaku

Member
Oct 12, 2001
122
0
0
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!
 

Superdoopercooper

Golden Member
Jan 15, 2001
1,252
0
0
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. :D
 

Killbat

Diamond Member
Jan 9, 2000
6,641
1
0
Sure thing, after you post a schematic for a 60Hz 115VAC -> 9VDC * 10A switching power supply. :p
 

Evadman

Administrator Emeritus<br>Elite Member
Feb 18, 2001
30,990
5
81


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



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>
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
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....
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81


<<

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



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 :D
 

Shalmanese

Platinum Member
Sep 29, 2000
2,157
0
0


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

lebe0024

Golden Member
Dec 6, 2000
1,101
0
76
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");
}
 

Locutus4657

Senior member
Oct 9, 2001
209
0
0
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!
>>