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

[size=medium]We know that information transmission means through the Ethernet consist of unicasting, multicasting, anycasting and broadcasting. The following table show differen forms of addressing.
[table]

| 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 |
[/table]


** 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.
[/size]


#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.
*/


[size=medium]
The above program will only exec 1 second which proves the above conclusion.
[/size]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值