Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multithreading

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming
General Programming  
Author Message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Tue Oct 31, 2006 5:02 pm    Post subject: Multithreading Reply with quote

How to check if a thread is running or has come out ?


"Save the return value of the CreateThread function. Use this handle in
the WaitForSingleObject function with timeout=0"
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Mon Dec 04, 2006 10:55 am    Post subject: Reply with quote

CreateThread and parameters?

"Is there a way to pass multiple parameters to the thread, instead of using global values?"
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Tue Dec 05, 2006 1:36 am    Post subject: Reply with quote

JoS: CPU at 100% but no benefit from 2 processors

"For example, on some test data, running them serially takes 49
seconds, while running in parallel takes 46-47 seconds. In the first case,
one processor is maxed out at 99%; in the second, TWO processors are
maxed out at 99% -- yet they take the same amount of time for the
same work!!"
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Thu Dec 14, 2006 9:13 am    Post subject: Reply with quote

C Board: _beginthreadex does not complile

"The multithreaded CRT is thread-safe, so _beginthreadex is in there,
but because you're compiling a debug build, the memory debug functions
are nowhere to be found.

MTd refers to... tada... the multithreaded debug CRT!"
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Dec 14, 2006 4:22 pm    Post subject: Reply with quote

CodeGuru: Function Static Variables in Multi-Threaded Environments

"This essentially means that the function will be anything but thread safe. One
very simple way to do this interlocking is to use the InterlockedCompareExchange()
function, which is guaranteed to be a synchronized operation."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Wed Jan 10, 2007 6:31 pm    Post subject: Reply with quote

CodeGuru: Simplified One-Time Initialization in Windows Vista

"For code that attempts to be clever and minimize the number of locks
taken out to guard the consistency of data structures accessible from
multiple threads, the x86 memory model provided a level of safety by
guaranteeing that all write operations occurred in order. This guarantee
does not hold true with the 64-bit processors, and code that reads data
without the protections of locks can experience unexpected results caused
by the processor reordering instructions."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Tue Jan 16, 2007 5:51 pm    Post subject: Reply with quote

CodeGuru: Framework for Writing Services and Multithreaded Applications

"I recently started a home project developing a set of middleware tools I am
hoping to flog on the Internet. Part of this involved writing NT services and
lightweight server side multithreaded applications. While doing this, I got a
little sidetracked (as I often do when time permits) and decided to knock up
a generic framework for things I find myself (re)writing frequently."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Tue Feb 13, 2007 8:11 pm    Post subject: Reply with quote

c board: Programming Threads Under Windows

"Good and simple tutorial. Windows advises people to use _beginthreadex()
instead of their CreateThread() API call."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Wed May 02, 2007 5:38 pm    Post subject: Reply with quote

cboard: Need help in Threading in win32

"The rule of thumb is simple: use _beginthreadex if you use any part of the C
or C++ standard library, CreateThread otherwise. Since you use the standard
library for a few things almost implicitly in C++, just always use _beginthreadex.
Better yet, use Boost.Thread."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sun Jun 17, 2007 11:21 am    Post subject: Reply with quote

JoS: Avoiding contention for the heap

"I was wondering if anyone could recommend any books, articles, or
web pages that address the topic of heap management in the context
of a multithreaded application."
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Tue Sep 04, 2007 4:43 pm    Post subject: Reply with quote

RC: Does creating a thread from DllMain deadlock or doesn't it?

"Creating a thread from DllMain is not recommended. The discussion here
has to do with explaining the behavior you may observe if you violate this
advice."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Tue Sep 11, 2007 11:34 am    Post subject: Reply with quote

JoS: How are OS threads implemented?

"But I've always wondered how threads are implemented, at the OS level.
From the perspective of the programs I wrote, everything executed sequentially,
without any interruption. But, from the perspective of the operating system
(and the CPU), any arbitrary code might be scheduled right in the middle of
my code, between any of my instructions."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Thu Oct 18, 2007 8:16 pm    Post subject: Reply with quote

RC: Win32 user interface work is inherently single-threaded

"You can push work to a background thread all you want, but once you send
a message to the window (or do something that results in a message being
sent to the window), you've given control to the UI thread."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Mon Jul 28, 2008 4:47 pm    Post subject: Reply with quote

RC: How can SIGINT be safely delivered on the main thread?

"Commenter AnotherMatt wonders why Win32 console programs deliver
console notifications on a different thread. Why doesn't it deliver them on
the main thread?

Actually, my question is the reverse. Why does unix deliver it on the main
thread? It makes it nearly impossible to do anything of consequence inside
the signal handler."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sun Apr 12, 2009 3:08 am    Post subject: Reply with quote

Marcus Zarra - Cocoa Tutorial: NSOperation and NSOperationQueue

"Fortunately, Apple has made a lot of progress in OS X 10.5 Leopard. NSThr-
ead itself has received a number of very useful new methods that make thr-
eading easier. In addition, they have introduced two new objects: NSOpera-
tion and NSOperationQueue. In this Tutorial I will walk through a basic exam-
ple that shows how to use these new Objects and how they make multi-thr-
eading your application nearly trivial."
Back to top
View user's profile Send private message Visit poster's website
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Thu Apr 30, 2009 7:04 pm    Post subject: Reply with quote

Ilya Martinov - volatile and threading

"It looks like if you put locks around global variables shared between
threads you shouldn't care about volatile flag. Definitely under POSIX
threads and most likely when using other threading libraries as well."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Tue Aug 11, 2009 7:06 pm    Post subject: Reply with quote

so - Reccomended thread layer to use for iPhone development?

"The problem I have is that I need another thread to block until an update
occurs... How can I make the main application thread block until at least one
CoreLocation update occurs? Is their an NSConditionVariable?"
Back to top
View user's profile Send private message Visit poster's website
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Sat Aug 15, 2009 6:04 pm    Post subject: Reply with quote

adc - Porting Multithreaded Applications from Win32 to Mac OS X

"Mac OS X offers application-level multithreading support in three different
API packages:
    * POSIX threads, or pthreads
    * Cocoa threads
    * Carbon Multiprocessing Services
The Win32 multithreading API does not have a native implementation of
condition variables. There have been many implementations of the condi-
tion variable model using available Win32 synchronization tools such as
events. The pthreads library contains a native implementation of condition
variables. While condition variables are still complex in nature, the fact that
they are supported natively in the library could help you simplify difficult
synchronization code."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Aug 27, 2009 3:49 pm    Post subject: Reply with quote

so - Overhead of pthread mutexes?

"I'm trying to make a C++ API (for Linux and Solaris) thread-safe, so that
its functions can be called from different threads without breaking internal
data structures. In my current approach I'm using pthread mutexes to pro-
tect all accesses to member variables."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Aug 27, 2009 3:55 pm    Post subject: Reply with quote

so - iPhone: multitasking, multithreading?

"Multithreading will work. It's multitasking that won't. The iphone won't let
more than one third party application run at once. That reasoning makes
fork live outside of the application's sandbox."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Aug 29, 2009 7:40 pm    Post subject: Reply with quote

so - How to kill a Thread with Objective C?

"The correct way to stop your thread executing is to ask it nicely to stop exe-
cuting. Then, in your thread, you listen for such requests and obey them at
an appropriate time."
Back to top
View user's profile Send private message
delovski



Joined: 14 Jun 2006
Posts: 3524
Location: Zagreb

PostPosted: Mon Nov 16, 2009 4:15 pm    Post subject: Reply with quote

MF - Simple Multithreading design

"I have an app that loops through each pixel of an image and calculates
the data at that point. Each pixel is completely independent of the others,
so there shouldn't be any synchronization issues."
Back to top
View user's profile Send private message Visit poster's website
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Dec 22, 2022 12:02 am    Post subject: Reply with quote

MS - Multithreading with C and Win32

"All versions of the CRT now support multithreading, with the exception of
the non-locking versions of some functions. For more information, see
Multithreaded libraries performance. For information on the versions of the
CRT available to link with your code, see CRT library features."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Dec 22, 2022 12:05 am    Post subject: Reply with quote

Paul E. McKenney - Is Parallel Programming Hard, And, If So, What
Can You Do About It?


"New releases should appear three to four times a year, give or take. This
work is covered by the terms of the Creative Commons Attribution-Share
Alike 3.0 United States license."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Wed Mar 29, 2023 6:35 pm    Post subject: Reply with quote

r - I rewrote my UNIX/X11 File Manager from scratch: code is simpler; threaded thumbnailing; alpha compositing with XRender; etc

"I have posted it here before.

At that time, I was using poll(2) for generating thumbnail images and
reading their paths, now it is done by a separate thread."

"Gettting a new error: widget.c:2959 PTHREAD_MUTEX_INITIALIZER

This can only be used in a static context, so you need to use
pthread_mutex_init. So you change it to:
pthread_mutex_init(&widget->lock,NULL);

With that change, builds fine (on Linux). Runs fine too. Very zippy little program."
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> General Programming All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group