`
lqy1987lqy
  • 浏览: 10945 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
最近访客 更多访客>>
社区版块
存档分类
最新评论

Reading notes for the 20th chapter 'Broadcasting' of unp.

    博客分类:
  • unp
 
阅读更多
We know that information transmission means through the Ethernet consist of unicasting, multicasting, anycasting and broadcasting. The following table show differen forms of addressing.
Type      IPv4 IPv6 TCP     UDP #IP interfaces identified #IP interfaces delivered to
Unicast   .    .    .       .   One            one           
Anycast   *    .    Not yet .   A set          one in set    
Multicast opt  .             .   A set          All in set    
broadcast .                   .   All            All           



** The disadvantage of broadcasting

When a computer node A broadcasted information in application level, it will be tranlated into physical level with use the dest Enet = ff:ff:ff:ff:ff:ff to transmit. The all nodes that are in same subnet with A will recevie the datagram in physical level and translate it to high level. This means that the all computers in the subnet will cached the datagram until the high level such as transmission level to discard if the destination is not match. But in unicasting style, they will not cache the datagram at all if the destination is not match.

** Race codition

A /race condition/ is usually when multiple processes are accessing data that is shared among them, but the correct outcome depends on the execution order of the processes.

Q: when a process is blocked at a function, a signal reaches which will interrupt the function. After the signal handler function return, will process return to execute that blocked function?

A: will not.


#include <stdio.h>
#include <signal.h>
#include <unistd.h>

static void do_alarm(int);
/* static had_alarm = 0; */

int main(){
	signal(SIGALRM, do_alarm);
	alarm(1);
	/* for( ; ; ){ */
/*		if(had_alarm == 1)
            break;
*/
		sleep(100);
		
		printf("Hello, world!\n");
		fflush(stdout);
	
	//}
	return 0;
}

static void do_alarm(int signo){
	printf("do alarm \n");
	fflush(stdout); 
/*	had_alarm = 1; */
	return;
}

/*
 * When redirect the output to a file, the
 * string 'do alarm' will partly missing, 
 * why? The reason is that i have not flush
 * the stdout buffer. when added fflush(stdout),
 * it works correctly.
 */



The above program will only exec 1 second which proves the above conclusion.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics