execution of a C program

This is a discussion on execution of a C program within the C Programming forums, part of the General Programming Boards category; I could not help but notice this : http://cboard.cprogramming.com/showthread.php?t=81290 I do know how functions work (parameter passing using the stack ...

  1. #1
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342

    execution of a C program

    I could not help but notice this :
    Getting a grasp on pointers

    I do know how functions work (parameter passing using the stack , flow of control etc) and the operations on the stack or heap, but I havent come across anything concrete that explains the exact procedure that is followed while memory is being allocated to a C program and such other things..Can someone guide me a little bit here ..

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    Because it's implementation-specific. The C standard only guarantees how the API will work, not the underlying hardware and lower-level system calls. On Linux, malloc() uses the sbrk() system call to deal with the heap. Not sure how Windows does it. I'm not sure how low-level you're looking to go, but you can run your program through strace (e.g. strace ./myprog) to see the system calls that are made.
    Last edited by itsme86; 07-27-2006 at 03:11 AM.
    If you understand what you're doing, you're not learning anything.

  3. #3
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by itsme86
    Because it's implementation-specific. The C standard only guarantees how the API will work, not the underlying hardware and lower-level system calls. On Linux, malloc() uses the sbrk() system call to deal with the heap. Not sure how Windows does it. I'm not sure how low-level you're looking to go, but you can run your program through strace (e.g. strace ./myprog) to see the system calls that are made.

    As I recall there's a book by the late W. Richard Stevens called "Advanced Programming in the Unix Environment."

    It has been a while since I picked it up, but as I recall, among other things, it talks about how programs execute in a Unix environment. Granted, it is very specific to Unix and is a bit dated now, but the basics are there.

    I picked mine up used on Amazon.

    It's worth a look to get a general idea.
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Granted, it is very specific to Unix and is a bit dated now, but the basics are there.
    The second edition has been published recently. For obvious reasons, Mr. Stevens wasn't a part of the update, but the new author appears to know what he's talking about and has the proper level of respect for the book.
    My best code is written with the delete key.

  5. #5
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by Prelude
    >Granted, it is very specific to Unix and is a bit dated now, but the basics are there.
    The second edition has been published recently. For obvious reasons, Mr. Stevens wasn't a part of the update, but the new author appears to know what he's talking about and has the proper level of respect for the book.
    Prelude,

    Thanks for the update. Stevens books have always been a very helpful part of my reference shelf, and I was dismayed that he wouldn't be around to bring them up to date.

    I'll have to check out that second edition.
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  6. #6
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    thanks for telling me about that book.. Do we have the online version or the one that allows free download available ? I checked in "google books" , it wasnt there. Unless i have overlooked.
    @MD : I dont think anyone even listens to u anymore....
    Last edited by kris.c; 07-27-2006 at 12:02 PM.

  7. #7
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Quote Originally Posted by kris.c
    thanks for telling me about that book.. Do we have the online version or the one that allows free download available ? I checked in "google books" , it wasnt there. Unless i have overlooked.
    @MD : I dont think anyone even listens to u anymore....

    I don't believe any of them are online.

    I did find the 2nd edition on Amazon for approximatley $65. If you're going to program in a *nix environment, I'd recommend getting it.

    Actually, all of Stevens' books are quite good, and from poking around it appears that they all might be getting updated.
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  8. #8
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    I will check up in my institute lib if i can find it...
    I work on linux day in and day out ( of late )
    > Actually, all of Stevens' books are quite good
    CAnt agree with u more.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  2. suspend execution of a program
    By majoub in forum C++ Programming
    Replies: 8
    Last Post: 07-28-2006, 07:34 AM
  3. invoke the execution of one c program from another
    By kris.c in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-09-2006, 12:10 AM
  4. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 08:51 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21