Thread: pthread heap separated like stack??

  1. #1
    Alessio Stella
    Join Date
    May 2008
    Location
    Italy, Bologna
    Posts
    251

    pthread heap separated like stack??

    (1)
    Is in C/C++ pthreads heap used by malloc/free or new/delete separated (one different heap for each thread) like stacks or not??

    (2)
    If I use the directives
    Code:
    #define ALIGN __attribute__ ((aligned (4))) 
    typedef struct 
    {
    
        	pthread_t   ALIGN     ThHandle;//not shared
        	sem_t ALIGN Termination;
        	
        	//pthread_mutex_t * BufStatusCommMutex_StatP;//not shared//duplicated
        	Type_SubCamera  Sub;//serialized by MainThread, implicitely (non mutexed) shared by Station and Camera
    } ALIGN Type_Camera;
    but then I allocate a Type_Camera with new is the alignment respected or not in the heap?
    And with malloc()?


    thank you

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    1) No.

    2) No, but 4-byte alignment is guaranteed by malloc anyway - actually malloc even guarantees 8-byte alignment, and might even guarantee 16-byte alignment on some machines.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  3. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  4. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 05:03 AM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM