LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-06-2010, 04:23 PM   #1
golmschenk
Member
 
Registered: Nov 2009
Posts: 144

Rep: Reputation: 15
C - What's the difference between a blocking and a non-blocking call?


What's the difference between a blocking and a non-blocking call in C?

Thanks!
 
Old 03-06-2010, 04:26 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Is this a direct homework question?

Just think logically about the question, irrespective of the programming language: one blocks the caller, the other doesn't. Do you know what that means?
 
Old 03-06-2010, 05:30 PM   #3
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
Quote:
Originally Posted by golmschenk View Post
What's the difference between a blocking and a non-blocking call in C?
About 7.

Sorry. Carry on.
 
Old 03-06-2010, 05:47 PM   #4
golmschenk
Member
 
Registered: Nov 2009
Posts: 144

Original Poster
Rep: Reputation: 15
Nope, not a direct homework question. Actually more or less I'm looking for the difference so much as what exactly blocking means. I just know I'm suppose to be using a blocking call in one case and non-blocking in the other and I'm trying to understand exactly what each does. Is it just that non-blocking doesn't wait for a return? Or...?
 
Old 03-06-2010, 05:57 PM   #5
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Exactly.

Blocking and non-blocking are just logical names to describe the behaviour of the functions. As the name implies, a blocking function blocks the calling function. This means the caller does not do anything until the blocking function returns control to it. You can consider this synchronous behaviour, because the interactions are "synchronized" in that the calling function must wait until the called blocking function is finished before continuing.

Conversely, non-blocking functions, of course, do the opposite: they do not require the caller to wait until they are finished. They simply call the function and immediately carry on to the next instruction to execute. This could be thought of as "asynchronous" interaction.

You could think of a personal, informal in-person conversation with someone as asynchronous. Each person doesn't necessarily wait until the other is finished their sentence. In a professional, formal conversation with your boss, its probably best to communicate synchronously: you do not want to interrupt while your boss is talking. You wait for him/her to finish talking, then you talk. (Aside: though your direction of communication with them is probably synchronous, they may communicate with you asynchronously, interrupting at will).

N.B.: Note that there are technical and programming-specific keywords for "synchronous", etc, so do not misuse these.

Last edited by nadroj; 03-06-2010 at 10:21 PM.
 
1 members found this post helpful.
Old 03-06-2010, 06:45 PM   #6
golmschenk
Member
 
Registered: Nov 2009
Posts: 144

Original Poster
Rep: Reputation: 15
Great! Thanks a bunch!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help regarding IP blocking Net_Spy Linux - Networking 1 10-12-2008 02:24 PM
System call and DMA blocking ppmim Programming 3 10-10-2008 12:51 PM
Blocking IP dellthinker Linux - Security 3 04-05-2007 12:13 PM
IP Blocking Help mortsahl Linux - Security 2 04-26-2004 08:29 AM
Killing a blocking system call diwana Programming 2 11-18-2003 11:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration