| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Dec 29, 2007 1:27 am Post subject: good uses of multi-threading? |
|
|
What are some good uses of multi-threading?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Sat Dec 29, 2007 1:35 am Post subject: |
|
|
| It allows you to do more tasks at the same time.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25956 Location: The netherlands
|
Posted: Sat Dec 29, 2007 2:00 am Post subject: |
|
|
doing processing in a seperate thread instead of the main thread, allowing a user to start another process at the same time.
also, on multicore cpu's not using multithreading is just wasting at least half of the system's functionality. Put those cores to use.
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Dec 29, 2007 9:56 am Post subject: |
|
|
I know what multi-threading is. I stated it wrong. I meant like examples of multi-threading in use.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Sat Dec 29, 2007 11:00 am Post subject: |
|
|
| Progress-bars are good examples . Also: when you create a form - it's a thread.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25956 Location: The netherlands
|
Posted: Sat Dec 29, 2007 12:05 pm Post subject: |
|
|
actually, a form isn't a thread, it's just event based (there's a main thread that handles messages of all windows and dispatches them to the correct functions and that loop can be called from code using application.processmessages)
anyhow, one example of threads is ce 5.4's new memory scanner.
It creates 2 threads on a dualcore and 4 threads on a quadcore, splits up the region to be scanned between the threads and scans them
Same for ce's pointerscanner, each time it goes through a list of results, and then assigns a result to a idle thread or when all threads are already working wait till one is done and give it the new task.
another use of multithreading would be in games. One thread doing physics, the other thread doing audio, one thread for AI, and another thread the rendering (e.g ut3 uses a lot of threading)
And you can also use it for little things, like ce's color changing on the process button. It's a low priority thread that changes the color continuesly.
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Dec 29, 2007 4:16 pm Post subject: |
|
|
Can someone explain to me a little more of the beginthread API in this code?
| Code: |
#include <stdio.h>
#include <windows.h>
#include <process.h> // needed for _beginthread()
void silly( void * ); // function prototype
int main()
{
// Our program's first thread starts in the main() function.
printf( "Now in the main() function.\n" );
// Let's now create our second thread and ask it to start
// in the silly() function.
_beginthread( silly, 0, (void*)12 );
// From here on there are two separate threads executing
// our one program.
// This main thread can call the silly() function if it wants to.
silly( (void*)-5 );
Sleep( 100 );
}
void silly( void *arg )
{
printf( "The silly() function was passed %d\n", (INT_PTR)arg ) ;
}
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Dec 29, 2007 4:31 pm Post subject: |
|
|
| Quote: |
_beginthread( silly, 0, (void*)12 );
|
| Quote: |
silly( (void*)-5 );
|
It's really the bolded parts I don't get.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25956 Location: The netherlands
|
Posted: Sat Dec 29, 2007 7:35 pm Post subject: |
|
|
it converts the value of 12 and -5 to a pointertype so the compiler won't complain, since the prototype of silly expects a pointer instead of a integer
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|