作者sky810675 (KKMAN)
看板TransCSI
标题[问题] 作业系统
时间Fri Aug 27 14:14:40 2010
A function is called reentrant if its computation results are correct even if
invoked by two or more processes simultaneously. Check if the following
function is reentrant. If it is not, modify it so that it is reentrant. You
can assume that you have synchronization primitives provided by an operating
system.
static int iCount;
void foo(int x, int *p) {
int y;
y = x * 7;
++p;
*p = 5678;
iCount *= 7890;
printf(“\nNew count: %d”, x);
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.101.251