01-29-2009
Quote:
Originally Posted by
naan
Hi,
Where are the static variables actually stored in memory. Is it in .bss? In that case how is its storage different from global variables?
Static variables are persistent for the duration of the program and are stored on the heap. The uninitialized ones are located in the bss section of the heap.
Quote:
Originally Posted by
naan
From the ELF data is it possible to see the storage of different variables used in the program?
eg:
static int temp1;
int gtemp1;
main() {
static int temp2;
.
.
}
In this code segment, are both temp1 and temp2 stored in .bss?
temp1 and temp2 will be located in the bss section of the heap as would be gtemp1 unless they were explicitly initialized.
8 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
I want a static variable in shell script.
I have a script in which I want to send mail on certain condition and it happens that when that condition is met it start mailing as i have set my cron job to execute every 15 mins.
And what i want is to run that script after every 15... (1 Reply)
Discussion started by: Yagami
1 Replies
2. Shell Programming and Scripting
Hi All,
I want a static variable in shell script.
I have a script in which I want to send mail on certain condition and it happens that when that condition is met it start mailing as i have set my cron job to execute every 15 mins.
And what i want is to run that script after every 15... (4 Replies)
Discussion started by: Yagami
4 Replies
3. IP Networking
hello, i need help on setting my coyote linux, i've working on this for last 5 days, can't get it to work. I've been posting this message to coyote forum, and other linux forum, but haven't get any answer yet. Hope someone here can help me...... please see my attached picture first.
... (0 Replies)
Discussion started by: dlwoaud
0 Replies
4. Shell Programming and Scripting
Dear Unix experts
I want to define a variable which contains dynmic and static part, daynamic part is the first field.
Sample of data
dddd aaaa sssss 12345
ssss 2323 234234 4242
dddd 3223 34234 54353
ssss 24234 3434 42342
dddd rwrw 423423 werwer
nawk 'BEGIN {FS=" "}{... (4 Replies)
Discussion started by: yahyaaa
4 Replies
5. Emergency UNIX and Linux Support
Dear Unix experts
Moved from "Shell Programming and Scripting "
I want to define a variable which contains dynmic and static part, daynamic part is the first field.
Sample of data
dddd aaaa sssss 12345
ssss 2323 234234 4242
dddd 3223 34234 54353
ssss 24234 3434 42342
dddd rwrw 423423... (2 Replies)
Discussion started by: yahyaaa
2 Replies
6. Programming
Hi,
Can any one tell me why my following program is crashing?
#include <iostream>
using namespace std;
class CA {
public:
const static int i;
};
const int CA::i = 10;
int main() {
int* pi = const_cast<int*>(&CA::i);
*pi = 9;
cout << CA::i << endl;
} (6 Replies)
Discussion started by: royalibrahim
6 Replies
7. Programming
We know that all the threads in process share the process address space.
We have various synchronization mechanisms like semaphore, mutex, spinlock, critical sections etc . used for thread syncronization.
I want to know in which part of the process address space are these synchronization... (2 Replies)
Discussion started by: rupeshkp728
2 Replies
8. Shell Programming and Scripting
Hi,
there is a file which contains some values in column format. I want to store those values in a variable.but when i am using awk it is storing all the values at a time.
x=`awk '{print $1}' test2.txt`
echo $x
ab cd mn jk yt
but i want the values to be stored one by one in that variable.... (3 Replies)
Discussion started by: arijitsaha
3 Replies
LEARN ABOUT OSF1
tis_cond_init
tis_cond_init(3) Library Functions Manual tis_cond_init(3)
NAME
tis_cond_init - Initializes a condition variable.
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <tis.h>
int tis_cond_init(
pthread_cond_t *cond);
STANDARDS
None
PARAMETERS
Address of the condition variable (passed by reference) to be initialized.
DESCRIPTION
This routine initializes a condition variable (cond) with the DECthreads default condition variable attributes.
A condition variable is a synchronization object used in conjunction with a mutex. A mutex controls access to shared data. When threads
are present, a condition variable allows threads to wait for data to enter a defined state.
For more information about actions taken when threads are present, refer to the pthread_cond_init(3) description.
Your program can use the macro PTHREAD_COND_INITIALIZER to initialize statically allocated condition variables to the DECthreads default
condition variable attributes. Static initialization can be used only for a condition variable with storage class extern or static - auto-
matic (stack local) objects must be initialized by calling tis_cond_destroy(3). Use this macro as follows:
pthread_cond_t condition = PTHREAD_COND_INITIALIZER
When statically initialized, a condition variable should not also be initialized using tis_cond_init(3).
RETURN VALUES
If an error condition occurs, the following occurs: The routine returns an integer value indicating the type of error. The condition vari-
able is not initialized. The contents of condition variable cond are undefined.
The possible return values are as follows: Successful completion. The system lacks the necessary resources to initialize another condition
variable, or The system-imposed limit on the total number of condition variables under execution by a single user is exceeded. The imple-
mentation has detected an attempt to reinitialize the object referenced by cond, a previously initialized, but not yet destroyed condition
variable. The value specified by attr is not a valid condition variable. Insufficient memory exists to initialize the condition variable.
ERRORS
None
RELATED INFORMATION
Functions: tis_cond_broadcast(3), tis_cond_destroy(3), tis_cond_signal(3), tis_cond_wait(3)
Manuals: Guide to DECthreads and Programmer's Guide
delim off
tis_cond_init(3)