473,386 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

thread safety

Hi,
I' ve to make a software module thread safe.
I know how to realize that and what' re the main topics of thread safety.
But I don' t know how thread safety can be tested. I read about a test for web servers. These apps' re tested with a stress test. That doesn' t work for my module. I searched the web but didn' t find a solution that satisfies me. I think that thread safety errors don' t occur reproduceable and so they' re hard to test and find.
Any ideas?

Thanks,
Alex.

Nov 15 '05 #1
9 2067
Alexander Fleck wrote:
Hi,
I' ve to make a software module thread safe.
I know how to realize that and what' re the main topics of thread safety.
But I don' t know how thread safety can be tested. I read about a test for web servers. These apps' re tested with a stress test. That doesn' t work for my module. I searched the web but didn' t find a solution that satisfies me. I think that thread safety errors don' t occur reproduceable and so they' re hard to test and find.
Any ideas?

Thanks,
Alex.


Threads and thread safety (and tools to examine them) are not
on topic in comp.lang.c. How threads work and which tools are
available is highly platform specific. You should give this
question a try in comp.unix.programmer or
comp.os.ms-windows.programmer.win32 or whatever targets you
are programming for.

<OT> a random example of such a tool for linux/pthreads:
http://valgrind.org/docs/manual/hg-manual.html </OT>

-David

Nov 15 '05 #2
Alexander Fleck wrote
(in article <de*************@news.t-online.com>):
Hi,
I' ve to make a software module thread safe.
I know how to realize that and what' re the main topics of thread safety.
But I don' t know how thread safety can be tested. I read about a test for
web servers. These apps' re tested with a stress test. That doesn' t work for my module. I searched the web but didn' t find a solution that satisfies me.
I think that thread safety errors don' t occur reproduceable and so they' re
hard to test and find.
Any ideas?


In addition to the other reply, see comp.programming.threads
--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #3
Randy Howard wrote:
Alexander Fleck wrote
I've to make a software module thread safe. I know how to realize
that and what' re the main topics of thread safety. But I don't
know how thread safety can be tested. I read about a test for web
servers. These apps' re tested with a stress test. That doesn't
work for my module. I searched the web but didn't find a solution
that satisfies me. I think that thread safety errors don' t occur
reproduceable and so they're hard to test and find.


In addition to the other reply, see comp.programming.threads


I think we can safely say that a function that calls only safe
functions, and uses only local storage and value parameters (not
pointers) is proof against most things.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 15 '05 #4
>Randy Howard wrote:
In addition to the other reply, see comp.programming.threads
[which is of course good advice.]

In article <43***************@yahoo.com>
CBFalconer <cb********@worldnet.att.net> wrote:I think we can safely say that a function that calls only safe
functions, and uses only local storage and value parameters (not
pointers) is proof against most things.


Except, perhaps, compilers and/or hardware that use
inherently-thread-unsafe code. (These do exist.) Presumably
a system that offers thread support at all will run on hardware
that is not inherently unsafe, and will offer compiler options
(perhaps the default, even) that are thread-safe in at least
most circumstances.

(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 15 '05 #5
Chris Torek <no****@torek.net> writes:
[...]
(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)


I believe the PDP-8 did that, though I don't know if it qualified as a
mainframe.

Note that this also made recursion impossible, or at least very
difficult.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #6
Op Sun, 28 Aug 2005 19:50:35 GMT schreef Keith Thompson:
Chris Torek <no****@torek.net> writes:
[...]
(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)


I believe the PDP-8 did that, though I don't know if it qualified as a
mainframe.

Note that this also made recursion impossible, or at least very
difficult.


And the HP 2100. I have some assembler manuals.
I did play a BASIC game, animals guessing(!) on it in about 1987.
--
Coos
Nov 15 '05 #7
On Sun, 28 Aug 2005 19:50:35 GMT, Keith Thompson <ks***@mib.org>
wrote:
Chris Torek <no****@torek.net> writes:
[...]
(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)


I believe the PDP-8 did that, though I don't know if it qualified as a
mainframe.

Note that this also made recursion impossible, or at least very
difficult.


It made re-entrancy difficult, as well. The Varian minicomputers did
this, with a trick of disabling interrupts for a cycle after the "jump
and mark" execution. This gave the programmer a chance to disable
interrupts and substitute non-entrancy for re-entrancy ;-)

Later, they introduced the "jump and set register" instruction, making
things a lot easier.
--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 15 '05 #8
On Sun, 28 Aug 2005 19:50:35 GMT, Keith Thompson <ks***@mib.org>
wrote:
Chris Torek <no****@torek.net> writes:
[...]
(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)
I believe the PDP-8 did that, though I don't know if it qualified as a
mainframe.

The 8's builtin "jump to subroutine" instruction JMS definitely does.
If you want you can construct your own calling sequence not using JMS
-- but since you have only one fully general register (AC) and can't
indirect through it directly(!), any reentrancy depends on conventions
for memory use or (optional) hardware.

It definitely isn't a mainframe though.

I think it was influentially the 709x that stores the return address
in the *low half* (address part) of X and executes from X+1; by
convention the high/opcode of X is already jump, so to return you jump
to X and as modified it jumps to the return point.
Note that this also made recursion impossible, or at least very
difficult.


Recursion is possible as it doesn't occur at arbitrary points like
interrupt or threads, but it is some work.

The PDP-10 had all three(!) popular options:
1) save PC' in X and execute from X+1; later jump indirect through X
2) save PC' in identified GPR and execute from X; later jump to reg
3) push PC' on stack using identified GPR; later pop from stack to PC

It also had other arguably excessive flexibilities, like all 16
possible 2-operand bitwise operations.

- David.Thompson1 at worldnet.att.net
Nov 15 '05 #9
In article <ef********************************@4ax.com>,
Dave Thompson <da*************@worldnet.att.net> wrote:
On Sun, 28 Aug 2005 19:50:35 GMT, Keith Thompson <ks***@mib.org>
wrote:
Chris Torek <no****@torek.net> writes:
[...]
(An example of hardware that is inherently "thread unsafe" is
the old mainframe machine -- I forget which one -- in which the
function-call instruction wrote the return address at the
first word of the target:

CALL foo
...
foo: .word 0 # reserved for return address
... machine code for function foo()
(begins by saving the return address on a stack
so that foo() can be called recursively; note that
the hardware does not offer direct support for stacks,
either, so we probably use a linked list obtained by
the underlying equivalent of malloc().)

Fortunately for most programmers, such hardware long ago went
out of style, and -- at least so far -- has not come back.)


I believe the PDP-8 did that, though I don't know if it qualified as a
mainframe.

The 8's builtin "jump to subroutine" instruction JMS definitely does.
If you want you can construct your own calling sequence not using JMS
-- but since you have only one fully general register (AC) and can't
indirect through it directly(!), any reentrancy depends on conventions
for memory use or (optional) hardware.

It definitely isn't a mainframe though.

I think it was influentially the 709x that stores the return address
in the *low half* (address part) of X and executes from X+1; by
convention the high/opcode of X is already jump, so to return you jump
to X and as modified it jumps to the return point.
Note that this also made recursion impossible, or at least very
difficult.


Recursion is possible as it doesn't occur at arbitrary points like
interrupt or threads, but it is some work.

The PDP-10 had all three(!) popular options:
1) save PC' in X and execute from X+1; later jump indirect through X
2) save PC' in identified GPR and execute from X; later jump to reg
3) push PC' on stack using identified GPR; later pop from stack to PC

It also had other arguably excessive flexibilities, like all 16
possible 2-operand bitwise operations.


It was built by the Tech Model Railroad Club after they graduated.

--
Michael Press
Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
4
by: The Crow | last post by:
for example i have static readonly SqlParameter and i want to clone them at runtime. as clone operation will not write to SqlParameter object, just reading, should i lock that object during read...
22
by: Brett | last post by:
I have a second thread, t2, that errors out and will stop. It's status is then "Stopped". I try to start t2 from thread 1, t1, by checking If t2.threadstate = "Stopped" Then t2.start() ...
4
by: Warren Sirota | last post by:
Hi, I've got a method that I want to execute in a multithreaded environment (it's a specialized spider. I want to run a whole bunch of copies at low priority as a service). It works well running...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
1
by: paul.hester | last post by:
Hi all, All of the classes in my DAL are static, with constants defining the stored procedures and parameters. I've been having some problems with my site which makes me wonder if there's a...
13
by: arun.darra | last post by:
Are the following thread safe: 1. Assuming Object is any simple object Object* fn() { Object *p = new Object(); return p; } 2. is return by value thread safe?
0
by: Graham Wideman | last post by:
Folks: Can anyone tell me what controls php's "thread safety" feature? I have an installation where phpinfo() is showing Thread safety: enabled, whereas I need it disabled in order to work...
13
by: Henri.Chinasque | last post by:
Hi all, I am wondering about thread safety and member variables. If I have such a class: class foo { private float m_floater = 0.0; public void bar(){ m_floater = true; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.