4/14/2009

Install VS 2008 on a Windows server (Sever 2003)

VS 2008 is to be installed on a 64-bit Windows Server 2003. Yet the VS Web Authoring Component continues to report problems (of HRESULT "-2147023293")...

As in [2], no use to look at the log in "dd_error_vs_vstscore_90.txt", which is quite high level. Yet what is useful is in %temp%SetupExe(***).log. The log says "Error: failed MsiEnumProducts ErrorCode: 2(0x2)."

A solution [1] can be located by googling the error, which perfectly solves the problem...

references:
1.http://support.microsoft.com/kb/954361
2.http://blog.mediawhole.com/2008/07/installing-visual-studio-2008.html

4/06/2009

多线程编程-共享变量的一致性

线程存储模型和变量映射
本质上,每个线程有自己完全独立的寄存器,但每个线程被允许共享进程的所有存储器空间。具体而言,读写区域(存储global variable, local static variable)和堆都是直接可以在thread routine里访问的(堆而言,只要指针能传进去)。栈而言(存储local variable),一般线程独立访问,但每个线程栈之间不设防:如也可以通过全局变量的方式让其他线程访问local variable.

共享变量的一致性:
当有多个线程访问一个变量实例(一个变量可能在不同的上下文(如方程,线程)有多个实例),可能导致不一致的现象。(系统对不同thread routine的汇编代码做interleaving的,且寄存器是完全独立的)

问题解决:通过信号量/互斥锁来同步线程,使得在临界区内只有一个线程。关键是对信号量的更新操作是原子的,不可中断的(应该是系统级别实现的)。

对于共享资源(如thread pool),如生产者/消费者模型,其本质和共享变量是相同的(相当于两个write操作)。

PS:
小细节:线程detach和joinable