Sponsored Content
Full Discussion: memory layout in C on linux
Top Forums Programming memory layout in C on linux Post 86343 by parasa on Thursday 13th of October 2005 09:10:17 AM
Old 10-13-2005
memory layout in C on linux

Hi,

Does any one know what tool to use to visualize how is memory layed out for C on linux systems. I mean how much stack portion is used in functional call.
Where exactly does the argument to function sit in memory ?

I have written small program pasted below. But I am not able to infer anything with the output I am getting.
(attached is the c code)
Global variable 'add' is used to locate the stack's base.


I don't know if this technique works ? waiting for your views

Regards,
Kiran
 

8 More Discussions You Might Find Interesting

1. Red Hat

Linux memory usage

What's the best way to find out how much memory is being used/available? I tried using free, but I didn't quite understand the output. Can someone explain it? $ free total used free shared buffers cached Mem: 16304536 16256376 48160 0 ... (6 Replies)
Discussion started by: junkmail426
6 Replies

2. UNIX for Advanced & Expert Users

Memory managment - linux

Hi, I having problem with my linux machine it have 6Gb physical memory and somehow it always almost coming to the bottom neck and than it start writing to the swap memory you can see that there is more than 4G in cahce, is there any way to clean the cache or to limit it to 2Gb? host1... (6 Replies)
Discussion started by: Igal Malka
6 Replies

3. Linux

Changing default keyboard layout in Linux

Hi I have Fedora linux with XFCE desktop. I want to use Indic lanquage in that. I have installed unicode devnagri fonts. But I am not able to change my default keyboard layout. How can I change default keyboard layout in XFCE or through command line. Thanks NeeleshG (0 Replies)
Discussion started by: neel.gurjar
0 Replies

4. Red Hat

share memory on linux

how to list the orphaned shared memory? how to kill them so that shared mem is free again. thanks (9 Replies)
Discussion started by: melanie_pfefer
9 Replies

5. Linux

Linux Memory Track

Hi All, We are using the linux servers and need to track the memory utilization of the box. Could anyone advice how the same can be achived. :) (1 Reply)
Discussion started by: haitorajesh
1 Replies

6. Programming

Memory sniffing in linux

I am trying to create an application that will be able to sniff memory of other applications. I am not completely new to systems programming but I am not sure how to go about this task. I understand that accomplishing this mainly require these steps. 1: Get a list of processes 2: Find the... (2 Replies)
Discussion started by: mosey
2 Replies

7. Red Hat

Shared memory in linux

Hello, I am using Linux os. $ df -k /dev/shm Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 2023256 1065000 958256 53% /dev/shm $ Based on my google this, it is shared memory. What is this shared memory and where exactly it is used? Can you... (5 Replies)
Discussion started by: govindts
5 Replies

8. Programming

"char" memory layout problem!

In the following code, why the final result of "usC=cA+(char)ucB;" is 0xFF00? In my opioion the memory layout of cA is "10000000" and (char)cB is "10000000",usC type is unsigned short ,so the result should be "100000000" ,the 0x100. Please help tell me what is wrong? Thanks!!;) ... (2 Replies)
Discussion started by: micky.zhou
2 Replies
pthread_attr_setstackaddr(3)				     Library Functions Manual				      pthread_attr_setstackaddr(3)

NAME
pthread_attr_setstackaddr - Changes the stack address attribute of the specified thread attributes object. LIBRARY
DECthreads POSIX 1003.1c Library (libpthread.so) SYNOPSIS
#include <pthread.h> int pthread_attr_setstackaddr( pthread_attr_t *attr, void *stackaddr); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: IEEE Std 1003.1c-1995, POSIX System Application Program Interface PARAMETERS
Address of the thread attributes object whose stack address attribute is to be modified. New value for the stack address attribute of the thread attributes object specified by attr. DESCRIPTION
This routine uses the value specified in the stackaddr argument to set the stack address attribute of the thread attributes object speci- fied in the attr argument. When creating a thread, use a thread attributes object to specify nondefault values for thread attributes. The stack address attribute of a thread attributes object points to the origin of the stack for a new thread. The default value for the stack address attribute of an initialized thread attributes object is NULL. For your program to calculate a value for the stackaddr attribute, note that: Your program must allocate the memory that will be used for the new thread's stack. On Tru64 UNIX, to create a new thread using a thread attributes object, the stackaddr attribute must be an address that points to the high-memory end of the memory region allocated for the stack. This address must point to the highest even-boundary quad- word in the allocated memory region. Also note that: If you use the pthread_attr_setstackaddr(3) routine to set a thread attributes object's stack address attribute and use that attributes object to create a new thread, DECthreads ignores the attributes object's guard- size attribute and provides no thread stack guard area for the new thread. If you use the same thread attributes object to create more than one thread and each created thread uses a nondefault stack address, you must use the pthread_attr_setstackaddr(3) routine to set a unique stack address attribute value for each new thread created using that attributes object. NOTES
Correct use of this routine depends upon details of the target platform's stack architecture. Thus, this routine cannot be used in a por- table manner. The size of the stack must be at least PTHREAD_STACK_MIN bytes (see pthread.h). However, because DECthreads must use a portion of this stack memory to begin thread execution and to maintain thread state, your program's "user thread code" cannot rely on using all of the stack memory allocated. RETURN VALUES
If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows: Successful completion. ERRORS
None RELATED INFORMATION
Functions: pthread_attr_getguardsize(3), pthread_attr_getstackaddr(3), pthread_attr_getstacksize(3), pthread_attr_init(3), pthread_attr_setguardsize(3), pthread_attr_setstacksize(3), pthread_create(3) Manuals: Guide to DECthreads and Programmer's Guide delim off pthread_attr_setstackaddr(3)
All times are GMT -4. The time now is 03:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy