should I worry?

This is a discussion on should I worry? within the C Programming forums, part of the General Programming Boards category; What does this mean: "This function is a cancellation point in multi-threaded programs. This is a problem if the thread ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    should I worry?

    What does this mean:

    "This function is a cancellation point in multi-threaded programs. This is a problem if the thread allocates some resources (like memory, file descriptors, semaphores or whatever) at the time read is called. If the thread gets canceled these resources stay allocated until the program ends. To avoid this, calls to read should be protected using cancellation handlers." (GNU)

    I'm asking because I just mistook a failed recv in a fork for a symptom of such (the message: "bad address"/file descriptor, the real problem: unallocated buffer). I hadn't realized forking counts as multi-threading (but it does according to wikipedia).

    If this is all true, what is the significance of the cancellation point?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    What the hell... I thought my post had gone through. Well now you get a lazy post since I have to retype stuff.

    fork() is for multi-threading. You can end up deadlocking threads. I wouldn't worry so much as be aware. And sometimes being aware means just making sure it doesn't happen instead of just hoping for the best.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by master5001 View Post
    What the hell... I thought my post had gone through. Well now you get a lazy post since I have to retype stuff.
    sorry master5001 -- I reduced that post to "nevermind" after i realized it was the unallocated buffer (that "bad address" error is a real "red herring") and I guess the mod took it down.

    Then I thought -- what if this is an issue anyway? So now I know, thanks.

    I'm not sure what I thought "multi-threading" meant before but it if that's it, then it makes sense
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Yeah its all good. I recall a time where I believe I should have known what multi-threading was and truly had no idea what it meant. Its just breaking up work. On a multi-CPU platform you can assign different work to different processors. Or on multi-core units you can assign different work to different cores. Or on fun systems with multi-core multi-processors, you can assign stuff all over the place.

    In a more basic nutshell though it is just separating work. You may want a client to connect, but not have your program cease to respond to other clients while the new client is receiving some sort of response to their request. So you have a separate thread handle each client. That things aren't waiting for one another.

    Now the kicker is that threads themselves can get stuck waiting around for one another.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem getting result when calling a function
    By drb2k2 in forum Windows Programming
    Replies: 1
    Last Post: 04-14-2003, 10:51 AM
  2. Comparing a string (case sensitive)
    By Waspntr in forum C++ Programming
    Replies: 9
    Last Post: 02-06-2003, 02:35 PM
  3. input files in C
    By LWisne in forum C Programming
    Replies: 4
    Last Post: 09-30-2002, 07:24 AM
  4. bothersome externs
    By Inquirer in forum C++ Programming
    Replies: 7
    Last Post: 07-29-2002, 02:28 PM
  5. monopoly..dont worry its not
    By iain in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-16-2001, 05:26 PM

Tags for this Thread


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