a thread safe stack?

G

Gernot Frisch

Hi,
I need a stack I can access from many threads simultanously. How do I
archive it? (No STL, please - real code)

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
J

Julie

Gernot said:
Hi,
I need a stack I can access from many threads simultanously. How do I
archive it? (No STL, please - real code)

What, STL is fake code?

Anyway, you are in the wrong newsgroup -- there isn't a way to do this w/
standard C++ language constructs in a platform independent way. You need to
take this question to a forum that discusses your OS and/or framework library.
 
P

Peter Koch Larsen

Gernot Frisch said:
Hi,
I need a stack I can access from many threads simultanously. How do I
archive it? (No STL, please - real code)

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
Your question is off-topic here. Try either
comp.for.men.c++.no_fucking_stl - or - comp.programming.threads.

/Peter
 
G

Gernot Frisch

Your question is off-topic here. Try either
comp.for.men.c++.no_fucking_stl - or - comp.programming.threads.

Sorry. I can't use STL in this project. I love STL for other projects.
If I set a "locked" bit on the buffer, that would be enough, no?
 
X

Xenos

Gernot Frisch said:
Hi,
I need a stack I can access from many threads simultanously. How do I
archive it? (No STL, please - real code)
Contrary to popular belief, it is possible in standard C++ to guarantee
mutal exclusion (such as Dekker's algorithm). Though, such methods are
never very efficient, and as such its best to use OS-specific calls.

Note: *everyone* asks this when starting out. No, just setting a
busy/in-use flag will not guarantee serialize access to the stack!

DrX
 
J

Jack Klein

Sorry. I can't use STL in this project. I love STL for other projects.
If I set a "locked" bit on the buffer, that would be enough, no?

What people are trying to tell you is that C++ does not have a
"locked" bit. The language has no support for multitasking at all.
All such code relies on platform-specific extensions supplied by the
operating system, and can differ with different operating systems and
compilers/libraries.

So it's off-topic here and needs to be asked in either a group that
specifically supports threads, such as comp.programming.threads as
suggested, or a group for your particular compiler/OS combination such
as or one of Microsoft's
support groups in the family.

It is not a C++ language question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

int(a) vs (int)a 19
a[3} slower than a.x; a.z; a.z 27
reference to parent inherritance? 9
queue where I can delete in the middle? 3
What's a smart pointer? 7
unreachable code? 4
reference to array? 13
date comparison 2

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top