[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]
[size=medium]
The above program will only exec 1 second which proves the above conclusion.
[/size]
[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]
本文深入探讨了信息传输中的广播、单播、泛播、多播等不同形式,并通过实例阐述了广播的缺点及进程间通信中信号处理的细节。同时,通过C语言程序展示了输出重定向时字符串丢失的原因及解决方法。
2092

被折叠的 条评论
为什么被折叠?



