A Concurrent Model for Imperative Languages with Improved Atomicity
Keehang Kwon, Daeseong Kang

TL;DR
This paper introduces a new concurrent programming model with block sequential statements that execute code blocks atomically, improving atomicity and predictability in imperative languages, exemplified by an extension of concurrent C.
Contribution
It presents a novel concurrent model featuring block sequential statements for atomic execution, enhancing control and predictability in imperative languages.
Findings
Introduces block sequential statement for atomic execution.
Extends concurrent C with new atomicity features.
Improves atomicity and predictability in concurrent programming.
Abstract
We propose a new concurrent model for imperative languages where concurrency occurs at a subprogram level. This model introduces a new {\it block sequential} statement of the form #(G_1,\ldots,G_n) where each is a statement. This statement tells the machine to execute sequentially and atomically (\ie, without interleaving). It therefore enhances atomicity and predictability in concurrent programming. We illustrate our idea via , an extension of the core concurrent C with the new block sequential statement.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
Topicssemigroups and automata theory · DNA and Biological Computing · Machine Learning and Algorithms
\field\authorlist\authorentry
Keehang KWONmlabelA \authorentryDaeseong KangnlabelB
\affiliate[labelA]The authors are with Computer Eng., DongA University. email:[email protected] \affiliate[labelB]The author is with Electronics Eng., DongA University. 11 11 \finalreceived200311
A Concurrent Model for Imperative Languages with Improved Atomicity
(2003; 2003)
keywords:
concurrency, imperative languages, block sequential.
{summary}
We propose a new concurrent model for imperative languages where concurrency occurs at a subprogram level. This model introduces a new block sequential statement of the form where each is a statement. This statement tells the machine to execute sequentially and atomically (i.e., without interleaving). It therefore enhances atomicity and predictability in concurrent programming.
We illustrate our idea via C*∥*, an extension of the core concurrent C with the new block sequential statement.
1 Introduction
Adding concurrency to imperative programming – C, its extension [6] and Java – is an attractive task. While concurrent programming may appear to be a simple task, it has proven too difficult to use, predict or debug.
An analysis shows that this difficulty comes from the fact that interleavings among threads – which are typically done by OS schedulers – are quite arbitrary and cannot be controlled at all by the programmer.
We observe that concurrent programming can be made easier by making interleaving less arbitrary and more controlled. Inspired by [4, 5], we propose two ideas for this. First, we propose a concurrent model with its own embedded scheduler. Our scheduler works on a high-level: it allows the execution to switch from one assigment statement to another. This is in contrast to OS schedulers which allows the execution to switch from one machine instruction to another. For example, the assignment statement is in the sense that it runs to completion without being interleaved. This reduces nondeterminism and error known as transient errors.
Second, semaphores and monitors are typically used as facilities for mutual exclusion. We propose a simpler method to solve mutual exclusion. Toward this end, we propose a new block sequential statement , where each is a statement. This has the following execution semantics: execute sequentially and consecutively (i.e., without being interleaved). In other words, our interpreter treats atomic. This can be easily implemented by designing our interpreter working in two different modes: the mode and the traditional mode. Thus, if our interpreter encounters , it switches from the concurrent mode to the sequential mode and proceeds just like the traditional C interpreter. In this way, atomicity of this statement is guaranteed. We intend to use this construct to each critical region.
This paper focuses on the minimum core of C, enhanced with concurrency at a subprogram level. This is to present the idea as concisely as possible. The remainder of this paper is structured as follows. We describe C*∥, an extension of concurrent C with a new statement in Section 2. In Section 3, we present an example of C∥*. Section 4 concludes the paper.
2 The Language
The language is core C with procedure definitions. It is described by - and -formulas given by the syntax rules below:
[TABLE]
In the above, represents a head of an atomic procedure definition of the form where are parameters. A -formula is called a procedure definition. In the transition system to be considered, a -formula will function as a thread and a set of -formulas (i.e., a set of threads) will function as the main statement, and a set of -formulas enhanced with the machine state (a set of variable-value bindings) will constitute a program. Thus, a program is a union of two disjoint sets, i.e., where each is a -formula and represents the machine state. Note that is initially set to an empty set and will be updated dynamically during execution via the assignment statements.
We will present an interpreter for our language via a proof theory [3, 8, 7, 9]. This is in contrast to other complex approaches to describing an interpreter for concurrent languages [1, 2]. Note that our interpreter alternates between the concurrent execution phase and the backchaining phase. In the concurrent execution phase (denoted by ) it tries to select and execute a thread among a set of threads () with respect to a program and produce a new program by reducing to simpler forms until becomes an assignment statement, true or a procedure call. The rules (4)-(11) deal with this phase. Here both and denote a set of -formulas. If becomes a procedure call, the interpreter switches to the backchaining mode. This is encoded in the rule (3). In the backchaining mode (denoted by ), the interpreter tries to solve a procedure call and produce a new program by first reducing a procedure definition in a program to its instance (via rule (2)) and then backchaining on the resulting definition (via rule (1)). To be specific, the rule (2) basically deals with argument passing: it eliminates the universal quantifier in by picking a value for so that the resulting instantiation, written as , matches the procedure call . The notation seqand denotes the sequential execution of two tasks. To be precise, it denotes the following: execute and execute sequentially. It is considered a success if both executions succeed. Similarly, the notation parand denotes the parallel execution of two tasks. To be precise, it denotes the following: execute and execute in any order. Thus, the execution order is not important here. It is considered a success if both executions succeed. The notation denotes reverse implication, i.e., .
Definition 1**.**
Let be a sequence of threads to run concurrently and let be a program. Then the notion of executing concurrently and producing a new program – – is defined as follows:
- (1)
* *
. % A matching procedure for is found.
- (2)
* *
. % argument passing
- (3)
* parand . % is a procedure call*
- (4)
. % True is always a success.
- (5)
. % Empty threads mean a success.
- (6)
* *
* seqand % evaluate to get *
**
% If an assignment statement is chosen by our interpreter, update to and return to the interpreter. Here, denotes a set union but in will be replaced by .
- (7)
* *
. % an empty sequential composition is a success.
- (8)
* *
* seqand *
. %
% If a sequential composition is chosen, execute in sequential mode and then return to the interpreter with the rest.
- (9)
* *
* seqand *
.
% If a repeat statement is chosen, execute in sequential mode and then return to the interpreter with the rest plus .
- (10)
*. *
% An empty block sequential statement is a success.
- (11)
* *
* seqand *
* seqand *
.
*% If a block sequential statement is chosen, execute in sequential mode and then in sequential mode and then return to the interpreter (which proceeds in concurrent mode) with the remaining. *
If has no derivation, then the interpreter returns the failure. Initially it works in the concurrent mode. In the concurrent mode, we assume that our interpreter chooses a thread using some predetermined algorithm. Note that executing thread concurrently, denoted by , is identical to executing sequentially.
3 Examples
As a well-known example, we examine the system that allows people to sign up for a mailing list. An example of this class is provided by the following code where the procedure below adds a person to a list:
[TABLE]
and the main program consists of two concurrent threads as follows:
[TABLE]
In the above, we used a more traditional notation instead of .
Although the above signup procedure is in fact a critical section, it works correctly because no interleaving – due to the presence of –is allowed in the critical section. Note that our code is very concise compared to the traditional ones using semaphores.
4 Conclusion
In this paper, we proposed a simple concurrent model for imperative languages. This model introduces a block sequential statement where each is a statement. This statement executes sequentially and atomically. It therefore enhances atomicity and predictability.
Although we focused on a simple concurrent model for imperative language at a subprogram level, it seems possible to apply our ideas to existing concurrent and parallel computing models [1, 2].
5 Acknowledgements
This work was supported by Dong-A University Research Fund.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] J. Alglave and L. Maranget and M. Tautschnig, “Herding cats: Modelling, simulation, teating and data mining for weak memory”, ACM Transactions on Programming Languages and Systems, vol.36, no.2, pp.1–74, 2014.
- 2[2] G. Boudol and G. Petri, “Relaxed memory models: an operational approach”, In POPL, pp.392–403, ACM, 2009.
- 3[3] G. Kahn, “Natural Semantics”, In the 4th Annual Symposium on Theoretical Aspects of Computer Science, LNCS vol. 247, 1987.
- 4[4] G. Japaridze, “Introduction to computability logic”, Annals of Pure and Applied Logic, vol.123, pp.1–99, 2003.
- 5[5] G. Japaridze, “Sequential operators in computability logic”, Information and Computation, vol.206, No.12, pp.1443-1475, 2008.
- 6[6] K. Kwon, S. Hur and M. Park, “Improving Robustness via Disjunctive Statements in Imperative Programming”, IEICE Transations on Information and Systems, vol.E 96-D,No.9, pp.2036-2038, September, 2013.
- 7[7] J. Hodas and D. Miller, “Logic Programming in a Fragment of Intuitionistic Linear Logic”, Information and Computation, vol.110, No.2, pp.327-365, 1994.
- 8[8] D. Miller, G. Nadathur, F. Pfenning, and A. Scedrov, “Uniform proofs as a foundation for logic programming”, Annals of Pure and Applied Logic, vol.51, pp.125–157, 1991.
