现今的并行编程实践多采用锁来同步对共享资源的访问,编程难且易出错;新引入的原子区构造虽简化了编程,但支持其实现的软硬件技术尚不令人满意.本文就同步提出一种新的语言级抽象-共享变量维持声明,它允许程序员从局部于线程的观点声明当前线程对某共享变量S访问的维持需求,即声明当前线程在运行时从上次访问S到这次访问S期间不允许其他线程访问S.从而,程序员无须考虑该如何使用锁等具体机制来同步对共享变量的访问,也可以避免或解决原子区所面临的一些问题.本文给出了共享变量维持声明的语法和语义描述,讨论了由这种声明信息生成共享变量访问控制代码的方法.
Nowadays the way to synchronously access the shared resources using locks in parallel programming is difficult to write and error-prone. The newly language construct of atomic section promises to make parallel programming easier, but the software and hardware technology to support atomic sections is not satisfied. This paper presents a new language abstract on synchronization mechanisms, i.e. holding declaration of shared variables. It allows programmers to declare the local holding requirement of some shared variable s in current thread, e.g. declaring that it is forbidden to access the shared variable s from other threads since the latest access to s in current thread. Therefore, programmers need not consider how to access shared variables with concrete synchronization mechanisms, such as using locks and so on, and can avoid or solve some problems confronted by atomic sections. In the paper, the syntax and the semantic description of the shared variable holding declaration are presented, and methods for generating the shared variable access control code from such declaration information are discussed.