471,330 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

basic threading question

Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.
Oct 31 '07 #1
4 931
On Oct 30, 7:58 pm, "bambam" <da...@asdf.asdfwrote:
Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.
Huh?

Oct 31 '07 #2
ch************@gmail.com wrote:
On Oct 30, 7:58 pm, "bambam" <da...@asdf.asdfwrote:
>Are function variables thread safe?

def f(a):
# whatever
return float(a)

Is that OK?

def f(a):
#whatever
b=a:
#whatever:
return float(b)

Is that OK?

Steve.

Huh?
If I have 37 threads, all calling a large function 'f', are the formal
parameters thread safe?

That is, will the formal parameters be trashed? Do you need to use
locks or semaphores before using formal parameters? Are the labels for
formal parameters static?

If I have 73 threads, all calling a large function 'f', are the local
values thread safe? Does each thread maintain it's own stack? Are the
labels for local values stack-based?

Steve.

Oct 31 '07 #3
[david] wrote:
If I have 37 threads, all calling a large function 'f', are the formal
parameters thread safe?

That is, will the formal parameters be trashed? Do you need to use
locks or semaphores before using formal parameters? Are the labels for
formal parameters static?

If I have 73 threads, all calling a large function 'f', are the local
values thread safe? Does each thread maintain it's own stack? Are the
labels for local values stack-based?
Yes. Each thread has its own stack, and that's where the parameter
bindings live.

Of course if you pass the same mutable object in multiple threads,
that's a different issue.
--
--Bryan
Oct 31 '07 #4
thanx :~)
Nov 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

65 posts views Thread by Anthony_Barker | last post: by
4 posts views Thread by Richard Spooner | last post: by
7 posts views Thread by asfwa | last post: by
7 posts views Thread by Anthony Nystrom | last post: by
3 posts views Thread by KC | last post: by
4 posts views Thread by Bob | last post: by
4 posts views Thread by DBC User | last post: by
2 posts views Thread by Chris Ashley | last post: by
19 posts views Thread by frankiespark | last post: by

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.