100% found this document useful (3 votes)
29 views

Download Complete Nonsequential and Distributed Programming with Go. Christian Maurer PDF for All Chapters

Distributed

Uploaded by

okurusulics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
29 views

Download Complete Nonsequential and Distributed Programming with Go. Christian Maurer PDF for All Chapters

Distributed

Uploaded by

okurusulics
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Get ebook downloads in full at ebookmeta.

com

Nonsequential and Distributed Programming with Go.


Christian Maurer

https://ebookmeta.com/product/nonsequential-and-distributed-
programming-with-go-christian-maurer/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://ebookmeta.com


Christian Maurer

Nonsequential
and Distributed
Programming
with Go
Synchronization of Concurrent Processes:
Communication
Cooperation
Competition
Nonsequential and Distributed Programming
with Go
Christian Maurer

Nonsequential and
Distributed Programming
with Go
Synchronization of Concurrent Processes:
Communication—Cooperation—
Competition
Christian Maurer
Institut für Informatik
Freie Universität Berlin
Berlin, Germany

ISBN 978-3-658-29781-7 ISBN 978-3-658-29782-4 (eBook)


https://doi.org/10.1007/978-3-658-29782-4

© Springer Fachmedien Wiesbaden GmbH, part of Springer Nature 2021


The translation was done with the help of artificial intelligence (machine translation by the service DeepL.
com). A subsequent human revision was done primarily in terms of content.
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or
hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does
not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective
laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are
believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors
give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions
that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps
and institutional affiliations.

Responsible Editor: Sybille Thelen


This Springer imprint is published by the registered company Springer Fachmedien Wiesbaden GmbH part of
Springer Nature.
The registered company address is: Abraham-Lincoln-Str. 46, 65189 Wiesbaden, Germany
Dedicated to my golden angel
Preface

First of all, we have to explain, why—by not following the “mainstream”—

“Nonsequential Programming”

was chosen as title of this book instead of

“Concurrent Programming”.

In the German language, there exist two words for “concurrent”:

• nebenläufig and
• nichtsequentiell.

The first word is the exact translation of “concurrent”1 , the second is simply the
negation of sequentiell, i.e. “nichtsequentiell” is just “not sequentiell”.
So, strictly speaking, “concurrent programming” means, that several developers are
working together to write a program, but makes no sense for a book title; whereas “non-
sequential programming” means the development of nonsequential programs, which is
our topic. Processes with access to shared resources may run concurrently on one or
more computers; algorithms, however, cannot be concurrent—they are either sequential
or not. This is probably the reason, why in all German universities lectures on this topic
are named “Nichtsequentielle Programmierung”.
This is why we prefer to use the German word for “nonsequential” in the context of
“programs” and “programming”, as in our opinion that adjective is much better suited
for this purpose, and stick to the German term in so far, as we use the spelling “nonse-
quential” instead of “non-sequential”. Furthermore,

 we will generally use the abbreviation “NSP” for “nonsequential


programming”.

1Latin: concurrere = cum + currere; cum = (together) with, currere = run, go, walk
vii
viii Preface

Basic techniques of nonsequential programming are either the subject of a separate


lecture in the bachelor's program of computer science studies or are part of lectures on
areas, in which nonsequential algorithms play an essential role.
This book systematically develops basic concepts for the synchronization of concur-
rent processes and for their communication2 —even in the distributed case:

• locks,
• semaphores,
• fairness and deadlocks,
• monitors,
• message passing,
• network-wide message passing.
• exploration of networks,
• traversal in networks and
• selection of a leader in them.

The algorithms are formulated in Go (see https://golang.org). Among other things,


this language is characterized by the following features:

• a C-like syntax (see https://golang.org/ref/spec)—but with significant influence from


Wirth's languages (see https://golang.org/doc/fac#history),
• the trend towards concise language and freedom from language stuttering of the kind
“ foo.Foo* myFoo = new(foo.Foo)”,
• garbage collection,
• the “rebellion” against cumbersome type systems such as e.g. in C++ or Java, and
consequently
• a very expressive type system with static type check when compiling a source text,
dynamic type adjustment at runtime as well as a rigid dependency analysis,
• but without type hierarchy (“types just are, they don't have to announce their relation-
ships”)—so lighter than in typical OO languages,
• “orthogonality of the concepts” (“methods can be implemented for any type; struc-
tures represent data while “interfaces” represent abstraction.”) and
• the installation of various constructs for NSP, including message passing—inspired
by Hoare's CSP calculus—as well as support for parallel, multicore and networked
computing.

2Latin: communicare = to communicate, to share, to discuss


Preface ix

More information can be found in the net at the beginning of the Frequently Asked
Questions by Go (https://golang.org/doc/faq).
To run the programs from the book, the installation of Go version 1.9 (or higher) is
assumed.
Basic knowledge of Go is certainly helpful for understanding the basic concepts, but
not necessary because of the simple syntax.
However, familiarizing yourself with Go is significantly (!) easier than, for example,
acquiring the knowledge in Java required to understand algorithms in comparable depth.
If you don't want to do this, you can understand the Go source texts “meta-linguisti-
cally”—such as the language-independent representations of algorithms in the textbooks
of Andrews, Ben-Ari, Herrtwich/Hommel, Raynal or Taubenfeld .
At “switching points”—locks, semaphores, monitors and network-wide message pass-
ing—some basic approaches to programming in C and Java are also presented.
Knowledge of imperative representations of abstract data objects, of the principles of
“information-hiding” and the basic concepts of object-oriented programming are how-
ever required; some important information—as far as it is needed for this book—can be
found in Chap. 2 about packages, interfaces and abstract data types.
The content structure is inductive:
The growing distance from the machine is associated with increasing abstraction,
which corresponds very naturally to the historical development of NSP: locks—sema-
phores—monitors—message passing. This structure can already be described as tradi-
tional, as it can also be found in most other textbooks.
Reading is therefore essentially only meaningful sequentially, i.e. in the order of the
chapters.
Focusing on Go would have offered an alternative order of the contents, starting with
the highest level of abstraction, the passing of messages via channels—a core concept
of this language—which is particularly recommended by its developers as the means
of choice for synchronization (see Sect. 1.9 on process states in the introduction and
Chap. 11 about messages). This path is deliberately not followed here, however, in order
to be able to use the book in environments in which other languages are favoured.
A fundamental principle of the book consists in the fact that the same classic exam-
ples are taken up again and again, which facilitates the comparison between the pre-
sented concepts and language tools.
The readers are strongly recommended,

• to work through these examples carefully in order to gain deeper insight into the simi-
larities and differences between the concepts,
• to perceive the suggestions for their own activities, i.e. to take up as many suggestions
for exercises as possible,
• to go ad fontes (original papers are fundamental sources, because they provide deeper
insights into the systematics of the development of NSP),
x Preface

• and—either—to install Go and get all examples and programs running—or—to


implement the algorithms in their preferred programming language, in order to
acquire practical programming competence.

Compared to the third edition, some bugs have been fixed and minor enhancements
added.
The essential difference to the 3rd edition, however, is that—due to a change in the
Go system—adjustments were required: The previous basic assumption that a value
assignment of a constant or variable to a variable of an elementary type is atomic is
now only valid in Go if the computer used has only one processor or if runtime.
GOMAXPROCS(1) was called.
Therefore, the value assignments to shared variables used in the entry and exit proto-
cols to protect critical sections now principally need to be replaced by an atomic instruc-
tion—realized with an indivisible machine instruction.
For some of the algorithms given in the book test runs can be carried out in which
their sequence is visualized dynamically. The corresponding program files, some of
which use C-library-routines and header files in /usr/include, are included in the source
texts of this book.
I would like to thank Mrs. Dipl.-Inf. Sybille Thelen from Springer-Verlag very much;
she also supported the publication of this edition very kindly again.
In June 2018 she informed me, that Springer Nature had selected my book among
some others to create in cooperation with DeepL an English version. I was very happy
about that idea and immediately agreed. In the middle of December 2019 I got the
result, but I after having read the first pages of it was a bit disappointed on quite a lot
of mistakes in the computer aided translation. The were some really funny ones as, e.g.,
“castle” and “lure” for lock, “trial” and “lawsuit” for process, “net curtain” for “store”,
“voltage tree” and “current beam” for spanning tree, “beacon” for signal, “embassy” for
message and “episode” for sequence and, furthermore, lots of things like the remarkable
statement “Any deterministic algorithm is deterministic, but not any deterministic algo-
rithm is necessary deterministic.” But there were also several of really annoying errors
such as grammar mistakes, rather strange orders of words in sentences and many wrong
translations that completely distorted contents. However, this experience implies, that I
will never sit in an AI-controlled car.
I have to thank the book production teams of Springer Nature, Heidelberg, and of
Scientific Publishing Services Ltd., Chennai: They have improved my corrections of the
DeepL-translation. I would also like to thank Mrs. Ivonne Eling for organizing things in
the background and Mr. Stefan Schmidt for several suggestions.
Finally, an important hint: Despite constant and thorough comparison of all source
texts reproduced in the book in the course of their development, it cannot be ruled out
with absolute certainty, that there are inconsistencies somewhere. (Hints to discovered
discrepancies or errors are of course very gratefully accepted!)
Preface xi

All source texts are is available on the pages of the book in the worldwide web:
https://maurer-berlin.eu/nspbook/4.

Berlin Christian Maurer


January 25th and November 20th 2020
Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Definition of Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Motivation and Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 The (Non-)Sense of Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Examples of Concurrent Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Concurrency and the Informal Notion of a Process . . . . . . . . . . . . . . . 11
1.6 Conflicts When Addressing Shared Data . . . . . . . . . . . . . . . . . . . . . . . 14
1.7 Atomic Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.8 Critical Sections and Lock Synchronization . . . . . . . . . . . . . . . . . . . . . 20
1.9 Process States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.9.1 Process Transitions in C, Java, and Go . . . . . . . . . . . . . . . . 23
1.9.2 Example in C, Java, and Go . . . . . . . . . . . . . . . . . . . . . . . . 30
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2 Packages, Interfaces, and Abstract Data Types . . . . . . . . . . . . . . . . . . . . . . . 33
2.1 The Role of Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1.1 Packages Only as Interfaces . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2 All Source Codes from This Book in the nUniverse Package . . . . . . . 36
2.3 The Package Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.1 Any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.2 Interfaces for Describing Objects . . . . . . . . . . . . . . . . . . . . 37
2.3.3 The Interface of the Package . . . . . . . . . . . . . . . . . . . . . . . . 40
2.3.4 Queues as Abstract Data Type . . . . . . . . . . . . . . . . . . . . . . . 41
2.3.5 A Queue as an Abstract Data Object . . . . . . . . . . . . . . . . . . 44
2.3.6 Bounded Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.4 On the Problem of References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3 Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1 Specification of Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 Locks in C, Java, and Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

xiii
xiv Contents

3.2.1 Locks in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.2.2 Locks in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.2.3 Locks in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.3 Locks Based on Indivisible Machine Instructions . . . . . . . . . . . . . . . . 53
3.3.1 Test and Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.3.2 Compare and Swap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.3.3 Exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.3.4 Decrement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.3.5 Fetch and Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.3.6 The Counter Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.3.7 Evaluation of the Use of Machine Instructions . . . . . . . . . . 61
3.4 Lock Algorithms for 2 Processes at High-Level Language Level . . . . 63
3.4.1 On the Indivisibility of Value Assignments . . . . . . . . . . . . . 63
3.4.2 Approaches to the Development of a Correct Algorithm . . . 64
3.4.3 Algorithm of Peterson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.4.4 Algorithm of Kessels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.4.5 Algorithm of Dekker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.4.6 Algorithm of Doran and Thomas . . . . . . . . . . . . . . . . . . . . 72
3.4.7 Algorithm of Hyman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3.5 Lock Algorithms for Several Processes . . . . . . . . . . . . . . . . . . . . . . . . 73
3.5.1 Tiebreaker Algorithm of Peterson . . . . . . . . . . . . . . . . . . . . 75
3.5.2 Algorithm of Dijkstra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.5.3 Algorithm of Knuth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3.5.4 Algorithm of Eisenberg and McGuire . . . . . . . . . . . . . . . . 80
3.5.5 Algorithm of Habermann . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.5.6 Ticket Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.5.7 Bakery Algorithm of Lamport . . . . . . . . . . . . . . . . . . . . . . . 83
3.5.8 Algorithm of Kessels for N Processes . . . . . . . . . . . . . . . . 85
3.5.9 Algorithm of Morris . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.5.10 Algorithm of Szymanski . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.6 Locks as Abstract Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
4.1 Disadvantages of the Implementation of Locks . . . . . . . . . . . . . . . . . . 97
4.2 Dijkstra’s Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.3 Binary Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.3.1 Equivalence of Locks and Binary Semaphores . . . . . . . . . . 100
4.3.2 Algorithm of Udding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
4.4 Buffers in the Nonsequential Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Contents xv

4.5 General Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105


4.5.1 Specification of General Semaphores . . . . . . . . . . . . . . . . . 106
4.5.2 Development of a Correct Implementation . . . . . . . . . . . . . 107
4.6 Unbounded Buffers and the Sleeping Barber . . . . . . . . . . . . . . . . . . . . 111
4.7 Construction of General Semaphores from Binary Semaphores . . . . . 115
4.7.1 Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.7.2 Naive (Wrong) Approach . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.7.3 Correction and Consequence . . . . . . . . . . . . . . . . . . . . . . . 118
4.7.4 The Algorithm of Barz . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
4.8 Semaphores in C, Java, and Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.8.1 Semaphores in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.8.2 Semaphores in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
4.8.3 Semaphores in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
4.9 Additive Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
4.9.1 Multiple Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.10 Barrier Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
4.11 Shortest Job Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.12 The Readers–Writers Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
4.12.1 The First Readers–Writers Problem . . . . . . . . . . . . . . . . . . 128
4.12.2 The Second Readers–Writers Problem . . . . . . . . . . . . . . . . 129
4.12.3 Priority Adjustment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.12.4 Implementation with Additive Semaphores . . . . . . . . . . . . 133
4.12.5 Efficient Implementation in Go . . . . . . . . . . . . . . . . . . . . . . 133
4.12.6 The Readers–Writers Problem as an Abstract Data Type . . . 133
4.13 The left–right Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
4.14 The Dining Philosophers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.15 The Problem of the Cigarette Smokers . . . . . . . . . . . . . . . . . . . . . . . . . 142
4.16 Implementation of Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
4.16.1 The Convoy Phenomenon . . . . . . . . . . . . . . . . . . . . . . . . . . 147
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5 The Baton Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.1 Development of the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.1.1 The Baton of Andrews . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.2 The Readers–Writers Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.3 The Second Left–Right Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
6 Universal Critical Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.1 Basic Idea and Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.1.1 Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
6.1.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
xvi Contents

6.2 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164


6.3 The Sleeping Barber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
6.4 The Readers–Writers Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
6.5 The Left–Right Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
6.6 Universal Critical Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
6.7 The Dining Philosophers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
6.8 The Problem of the Cigarette Smokers . . . . . . . . . . . . . . . . . . . . . . . . . 174
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
7 Fairness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
7.1 Weak Versus Strong Fairness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
8 Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8.1 Characterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8.1.1 A Simple Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.2 Countermeasures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
8.2.1 Prevention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
8.2.2 Detection and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
8.2.3 Avoidance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.2.4 The Bankers’ Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
8.3 Probability of Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
8.4 Evaluation of the Countermeasures . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
9 Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
9.1 Characterization of Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
9.1.1 Hoare’s Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
9.1.2 Virtual Monitors in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
9.2 Condition Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
9.3 Monitors in C, Java, and Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
9.3.1 Monitors in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
9.3.2 Monitors in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
9.3.3 Monitors in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
9.4 The Bounded Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
9.5 The Readers–Writers Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
9.6 Signal Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
9.6.1 Signal and Continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
9.6.2 Signal and Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
9.6.3 Signal and Urgent Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
9.6.4 Preemptive Versus Nonpreemptive Semantics . . . . . . . . . . 210
9.6.5 Comparing Evaluation of the Signal Semantics . . . . . . . . . 211
9.6.6 A Semaphore as Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . 211
9.6.7 Barrier Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Contents xvii

9.7 Broadcast in C, Java, and Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214


9.7.1 Broadcast in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
9.7.2 Broadcast in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
9.7.3 Broadcast in Go . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
9.8 The Sleeping Barber: Haircut as a Rendezvous . . . . . . . . . . . . . . . . . . 216
9.9 Priority Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
9.9.1 Hoare’s Alarm Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
9.9.2 Shortest Job next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
9.10 Equivalence of the Semaphore and the Monitor Concepts . . . . . . . . . . 220
9.11 Implementation of the Monitor Concept . . . . . . . . . . . . . . . . . . . . . . . . 223
9.12 The Problem of Nested Monitor Calls . . . . . . . . . . . . . . . . . . . . . . . . . 225
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
10 Universal Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
10.1 The Basic Idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
10.1.1 Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
10.1.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
10.2 Conditioned Universal Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
10.2.1 Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
10.2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
10.3 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
10.4 Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
10.5 Bounded Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
10.6 The Sleeping Barber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
10.7 Barrier Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
10.8 The Readers–Writers Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
10.9 The Left–Right Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
10.10 The Dining Philosophers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
10.11 The Cigarette Smokers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
11 Message Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
11.1 Channels and Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
11.1.1 Syntax of Message Passing in Go . . . . . . . . . . . . . . . . . . . . 247
11.1.2 Synchronous Message Passing with Asynchronous . . . . . . 249
11.2 Asynchronous Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
11.2.1 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
11.2.2 Bounded Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
11.2.3 The Cigarette Smokers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
11.3 Networks of Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
11.3.1 Caesar’s Secret Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 252
11.3.2 The Sieve of Eratosthenes . . . . . . . . . . . . . . . . . . . . . . . . . . 254
11.3.3 Mergesort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
11.3.4 The Dining Philosophers . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Other documents randomly have
different content
to one of his “Fabliaux.” A sinner lies dying, and an angel and a
fiend, after disputing the right to his soul, agree to settle the affair by
a throw of dice. The fiend gets the first chance, and the fatal cubes
come up—two sixes! He chuckles and rubs his claws, for everybody
knows that no higher number is possible. But the angel thinks
otherwise, throws, and, behold, a six and seven! And thus it is, that
when the understanding has done its best, when it has reached, as it
thinks, down to the last secret of music and meaning that language
is capable of, the poetical sense comes in with its careless miracle,
and gets one more point than there are in the dice.

Imagination is not necessarily concerned with poetic expression.


Nothing can be more poetical than the lines of Henry More the
Platonist:

What doth move


The nightingale to sing so fresh and clear?
The thrush or lark, that mounting high above,
Chants her shrill notes to heedless ears of corn,
Heavily hanging in the dewy morn.

But compare it with Keats’

Ruth, when sick for home,


She stood in tears amid the alien corn.

The imagination has touched that word “alien,” and in it we see the
field through Ruth’s eyes, as she looked round on the hostile spikes,
and not through those of the poet.

Imagination enters more or less into the composition of all great


minds, all minds that have what we call breadth as distinguished
from mere force or acuteness. We find it in philosophers like Plato
and Bacon, in discoverers like Kepler and Newton, in fanatics like
George Fox, and in reformers like Luther.
The shape which the imaginative faculty will take is modified by the
force of the other qualities with which it is coördinated in the mind. If
the moral sense predominates, the man becomes a reformer, or a
fanatic, and his imagination gets itself uttered in his life. Bunyan
would have been nothing but a fanatic, if he had not been luckily
shut up in Bedford jail, alone with his imagination, which, unable to
find vent in any other way, possessed and tortured him till it had
wrung the “Pilgrim’s Progress” out of him—a book the nearest to a
poem, without being one, that ever was written. Uniting itself with the
sense of form, Imagination makes a sculptor; with those of form and
color, a painter; with those of time and tune, a musician. For in itself
it is dumb, and can find expression only through the help of some
other faculty.

Imagination plus the poetic sense is poesy, minus the poetic sense it
is science, though it may clothe itself in verse. To those who are
familiar with Dr. Donne’s verses, I need only mention his name as a
proof of my last position. He solves problems in rhyme, that is all.

Shakspeare was so charged with the highest form of the poetic


imagination, as some persons are with electricity, that he could not
point his finger at a word without a spark of it going out of him. I will
illustrate it by an example taken at random from him. When Romeo
is parting from Juliet, Shakspeare first projects his own mind into
Romeo, and then, as Romeo becomes so possessed with the
emotion of the moment that his words take color from it, all nature is
infected and is full of partings. He says:

But look what envious streaks


Do lace the severing clouds.

Shakspeare’s one hundred and thirteenth sonnet was here also


quoted in illustration.

The highest form of imagination, Mr. Lowell said, is the dramatic, of


which Shakspeare must always stand for the only definition. Next is
the narrative imagination, where the poet forces his own personal
consciousness upon us and makes our senses the slaves of his
own. Of this kind Dante’s “Divina Commedia” is the type. Below this
are the poems in which the imagination is more diffused; where the
impression we receive is rather from mass than from particulars;
where single lines are not so strong in themselves as in forming
integral portions of great sweeps of verse; where effects are
produced by allusion and suggestion, by sonorousness, by the use
of names which have a traditional poetic value. Of this kind Milton is
the type.

Lastly, said Mr. Lowell, I would place in a class by themselves those


poets who have properly no imagination at all, but only a pictorial
power. These we may call the imaginary poets, writers who give us
images of things that neither they nor we believe in or can be
deceived by, like pictures from a magic lantern. Of this kind are the
Oriental poems of Southey, which show a knowledge of Asiatic
mythologies, but are not livingly mythologic.

Where the imagination is found in combination with great acuteness


of intellect, we have its secondary or prose form. Lord Bacon is an
example of it. Sir Thomas Browne is a still more remarkable one—a
man who gives proof of more imagination than any other Englishman
except Shakspeare.

Fancy is a frailer quality than Imagination, and cannot breathe the


difficult air of the higher regions of intuition. In combination with
Sentiment it produces poetry; with Experience, wit. The poetical
faculty is in closer affinity with Imagination; the poetical temperament
with Fancy. Contrast Milton with Herrick or Moore. In illustration Mr.
Lowell quoted from Marvell, the poet of all others whose fancy hints
always at something beyond itself, and whose wit seems to have
been fed on the strong meat of humor.

As regards man, Fancy takes delight in life, manners, and the result
of culture, in what may be called Scenery; Imagination is that
mysterious something which we call Nature—the unfathomed base
on which Scenery rests and is sustained. Fancy deals with feeling;
Imagination with passion. I have sometimes thought that
Shakspeare, in the scene of the “Tempest,” intended to typify the isle
of Man, and in the characters, some of the leading qualities or
passions which dwell in it. It is not hard to find the Imagination in
Prospero, the Fancy in Ariel, and the Understanding in Caliban; and,
as he himself was the poetic imagination incarnated, is it considering
too nicely to think that there is a profound personal allusion in the
breaking of Prospero’s wand and the burying of his book to the
nature of that man who, after such thaumaturgy, could go down to
Stratford and live there for years, only collecting his dividends from
the Globe Theatre, lending money on mortgage, and leaning over
the gate to chat and chaffer with his neighbors?

I think that every man is conscious at times that it is only his borders,
his seaboard, that is civilized and subdued. Behind that narrow strip
stretches the untamed domain, shaggy, unexplored, of the natural
instincts. Is not this so? Then we can narrow our definition yet
farther, and say that Fancy and Wit appear to the artificial man;
Imagination and Humor to the natural man. Thus each of us in his
dual capacity can at once like Chaucer and Pope, Butler and Jean
Paul, and bury the hatchet of one war of tastes.

And now, finally, what is the secret of the great poet’s power over
us? There is something we love better than love, something that is
sweeter to us than riches, something that is more inspiring to us than
success—and that is the imagination of them. No woman was ever
loved enough, no miser was ever rich enough, no ambitious man
ever successful enough, but in imagination. Every desire of the heart
finds its gratification in the poet because he speaks always
imaginatively and satisfies ideal hungers. We are the always-
welcome guests of his ennobling words.

This, then, is why the poet has always been held in reverence
among men. All nature is dumb, and we men have mostly but a
stunted and stuttering speech. But the longing of every created thing
is for utterance and expression. The Poet’s office, whether we call
him Seer, Prophet, Maker, or Namer, is always this—to be the Voice
of this lower world. Through him, man and nature find at last a
tongue by which they can utter themselves and speak to each other.
The beauties of the visible world, the trembling attractions of the
invisible, the hopes and desires of the heart, the aspirations of the
soul, the passions and the charities of men; nay, the trees, the rocks,
our poor old speechless mother, the earth herself, become voice and
music, and attain to that humanity, a divine instinct of which is
implanted in them all.
LECTURE II
PIERS PLOUGHMAN’S VISION

(Friday Evening, January 12, 1855)

II
In literature, as in religion and politics, there is a class of men who
may be called Fore-runners. As there were brave men before
Agamemnon, so there must have been brave poets before Homer.
All of us, the great as well as the little, are the result of the entire
Past. It is but just that we should remember now and then that the
very dust in the beaten highways of thought is that of perhaps
nameless saints and heroes who thought and suffered and died to
make commonplace practicable to us. Men went to the scaffold or
the stake for ideas and principles which we set up in our writings and
our talk as thoughtlessly as a printer sticks his type, and the country
editor, when he wrote his last diatribe on the freedom of the press,
dipped his pen without knowing it in the blood of the martyrs. It would
be well for us to remember, now and then, our dusty benefactors,
and to be conscious that we are under bonds to the Present to the
precise amount that we are indebted to the Past.

Thus, from one point of view, there is nothing more saddening than a
biographical dictionary. It is like a graveyard of might-have-beens
and used-to-be’s, of fames that never ripened and of fames already
decayed. Here lies the great Thinker who stammered and could not
find the best word for his best thought, and so the fame went to
some other who had the gift of tongues. Here lies the gatherer of
great masses of learning from which another was to distil the
essence, and to get his name upon all the phials and show-bills. But
if these neglected headstones preach the vanity of a selfish
ambition, they teach also the better lesson that every man’s activity
belongs not to himself but to his kind, and whether he will or not
must serve at last some other, greater man. We are all foot-soldiers,
and it is out of the blood of a whole army of us that iron enough is
extracted to make the commemorative sword that is voted to the
great Captain.

In that long aqueduct which brings the water of life down to us from
its far sources in the Past, though many have done honest day-labor
in building it, yet the keystone that unites the arch of every period is
engraved with the name of the greatest man alone. These are our
landmarks, and mentally we measure by these rather than by any
scheme of Chronology. If we think of Philosophy, we think of four or
five great names, and so of Poetry, Astronomy, and the rest. Geology
may give what age she will to the globe; it matters not, it will still be
only so many great men old; and wanting these, it is in vain that
Egypt and Assyria show us their long bead-roll of vacant centuries. It
is in the life of its great men that the life and thought of a people
becomes statuesque, rises into poetry, and makes itself sound out
clearly in rhythm and harmony.

These great persons get all the fame and all the monuments like the
generals of armies, though we may lead the forlorn hope, or make a
palpitating bridge with our bodies in the trenches. Rank and file may
grumble a little—but it is always so, and always must be so. Fame
would not be fame if it were or could be divided infinitesimally, and
every man get his drachm and scruple. It is good for nothing unless it
come in a lump. And besides, if every man got a monument or an
epitaph who felt quite sure he deserved it, would marble hold out, or
Latin?

The fame of a great poet is made up of the sum of all the


appreciations of many succeeding generations, each of which he
touches at some one point. He is like a New World into which
explorer after explorer enters, one to botanize, one to geologize, one
to ethnologize, and each bringing back his report. His great snowy
mountains perhaps only one man in a century goes to the top of and
comes back to tell us how he saw from them at once the two great
oceans of Life and Death, the Atlantic out of which we came, the
Pacific toward which we tend.

Of the poet we do not ask everything, but the best expression of the
best of everything. If a man attain this but once, though only in a frail
song, he is immortal; while every one who falls just short of it, if only
by a hair’s breadth, is as sure to be forgotten. There is a wonderful
secret that poets have not yet learned, and this is that small men
cannot do great things, but that the small man who can do small
things best is great. The most fatal ill-success is to almost succeed,
as, in Italy, the worst lemons are those large ones which come
nearest to being oranges. The secret of permanent fame is to
express some idea the most compactly, whether in your life, your
deed, or your writing. I think that if anything is clear in history, it is
that every idea, whether in morals, politics, or art, which is laboring
to express itself, feels of many men and throws them aside before it
finds the one in whom it can incarnate itself. The noble idea of the
Papacy (for it was a noble one—nothing less than the attempt to
embody the higher law in a human institution) whispered itself to
many before it got the man it wanted in Gregory the Great. And
Protestantism carried numbers to the stake ere it entered into Luther:
a man whom nature made on purpose—all asbestos so that he could
not burn. Doubtless Apollo spoiled many a reed before he found one
that would do to pipe through even to the sheep of Admetus, and the
land of song is scattered thick with reeds which the Muse has
experimented with and thrown away.

It is from such a one that I am going to try to draw a few notes of


music and of mirth to-night. Contemporary with Chaucer lived a man
who satirized the clergy and gave some lively pictures of manners
before the “Canterbury Tales” were written. His poem was very
popular, as appears from the number of manuscript copies of it
remaining, and after being forgotten for two centuries, it was revived
again, printed, widely read, and helped onward the Reformation in
England. It has been reprinted twice during the present century. This
assures us that it must have had a good deal of original force and
vivacity. It may be considered, however, to be tolerably defunct now.
This poem is the vision of Piers Ploughman.
I have no hope of reviving it. Dead poets are something very dead,
and critics blow their trumpets over them in vain. What I think is
interesting and instructive in the poem is that it illustrates in a
remarkable manner what may be considered the Anglo-Saxon
element in English poetry. I refer to race, and not to language. We
find here a vigorous common-sense, a simple and hearty love of
nature, a certain homely tenderness, held in check always by a
dogged veracity. Instead of Fancy we have Feeling; and, what more
especially deserves notice, there is almost an entire want of that
sense of form and outline and proportion which alone brings
anything within the province of Art. Imagination shows itself now and
then in little gleams and flashes, but always in the form of Humor.
For the basis of the Anglo-Saxon mind is beef and beer; what it
considers the real as distinguished from, or rather opposed to, the
ideal. It spares nothing merely because it is beautiful. It is the Anglo-
Saxon who invented the word Humbug, the potent exorcism which
lays the spirit of poetry in the Red Sea. It is he who always translates
Shows into Shams.

Properly speaking, “Piers Ploughman’s Vision” is not a poem at all. It


is a sermon rather, for no verse, the chief end of which is not the
representation of the beautiful, and whose moral is not included in
that, can be called poetry in the true sense of the word. A thought
will become poetical by being put into verse when a horse hair will
turn into a snake by being laid in water. The poetical nature will
delight in Mary Magdalen more for her fine hair than for her
penitence. But whatever is poetical in this book seems to me
characteristically Saxon. The English Muse has mixed blood in her
veins, and I think that what she gets from the Saxon is a certain
something homely and practical, a flavor of the goodwife which is
hereditary. She is the descendant on one side of Poor Richard,
inspired, it is true, but who always brings her knitting in her pocket.
The light of the soul that shines through her countenance, that “light
that never was on land or sea,” is mingled with the warm glow from
the fireside on the hearth of Home. Indeed, may it not be attributed
to the Teutonic heart as something peculiar to it, that it has breadth
enough to embrace at once the chimney-corner and the far-reaching
splendors of Heaven? Happy for it when the smoke and cookery-
steam of the one do not obscure the other!

I find no fault with the author of Piers Ploughman for not being a
poet. Every man cannot be a poet (fortunately), nor every poet a
great one. It is the privilege of the great to be always
contemporaneous, to speak of fugacious events in words that shall
be perennial. But to the poets of the second rate we go for pictures
of manners that have passed away, for transitory facts, for modes of
life and ways of thinking that were circumstantial merely. They give
us reflections of our outward, as their larger brethren do of our
inward, selves. They deal, as it were, with costume; the other with
man himself.

But these details are of interest, so fond are we of facts. We all have
seen the congregation which grew sleepy while the preacher talked
of the other world give a stir of pleased attention if he brought in a
personal anecdote about this. Books are written and printed, and we
read them to tell us how our forefathers cocked their hats, or turned
up the points of their shoes; when blacking and starch were
introduced; who among the Anglo-Saxons carried the first umbrella,
and who borrowed it.

These trifles, also, acquire importance in proportion as they are


older. If a naturalist showed us a toad, we should be indifferent, but if
he told us that it had been found in a block of granite, we should
instantly look with profound interest on a creature that perhaps ate
moths in Abel’s garden, or hopped out of the path of Lamech. And
the same precious jewel of instruction we find in the ugly little facts
embedded in early literatures. They teach us the unchangeableness
of man and his real independence of his accidents. He is the same
old lay figure under all his draperies, and sits to one artist for a John
and to another for a Judas, and serves equally well for both portraits.
The oldest fable reappears in the newest novel. Aristophanes makes
coats that fit us still. Voltaire is Lucian translated into the eighteenth
century. Augustus turns up in Louis Napoleon. The whirligig of Time
brings back at regular intervals the same actors and situations, and
under whatever names—Ormuzd and Ahriman, Protestantism and
Catholicism, Reform and Conservatism, Transcendentalism and
Realism. We see the same ancient quarrel renewed from generation
to generation, till we begin to doubt whether this be truly the steps of
a Tower of Babel that we are mounting, and not rather a treadmill,
where we get all the positive good of the exercise and none of the
theoretic ill which might come if we could once solve the problem of
getting above ourselves. Man’s life continues to be, as the Saxon
noble described it, the flight of a sparrow through a lighted hall, out
of one darkness and into another, and the two questions whence?
and whither? were no tougher to Adam than to us. The author of
Piers Ploughman’s Vision has offered us his theory of this world and
the next, and in doing so gives some curious hints of modes of life
and of thought. It is generally agreed that one of his names was
Langland, and it is disputed whether the other was Robert or William.
Robert has the most authority, and William the strongest arguments
in its favor. It is of little consequence now to him or us. He was
probably a monk at Malvern. His poem is a long one, written in the
unrhymed alliterative measure of the Anglo-Saxon poetry, and the
plan of it is of the simplest kind. It is a continued allegory, in which all
the vices, passions, and follies of the time, the powers of the mind,
the qualities of the spirit, and the theological dogmas of the author,
are personified and mixed up with real personages with so much
simplicity, and with such unconscious interfusion of actual life as to
give the whole an air of probability.

The author of Piers Ploughman’s Vision avoids any appearance of


incongruity by laying his scene in a world which is neither wholly real
nor wholly imaginary—the realm of sleep and dreams. There it does
not astonish us that Langland should meet and talk with the
theological virtues, and that very avoirdupois knights, monks, abbots,
friars, and ploughmen should be found in company with such
questionable characters as Do-well, Do-better, Do-best, Conscience,
Nature, Clergy, and Activa Vita. He has divided his poem into twenty
“steps,” as he calls them, in each of which he falls asleep, has a
dream, and wakes up when it becomes convenient or he is at a loss
what else to do. Meanwhile his real characters are so very real, and
his allegorical ones mingle with them on such a common ground of
easy familiarity, that we forget the allegory altogether. We are not
surprised to find those Utopian edifices, the Tower of Truth and the
Church of Unity, in the same street with an alehouse as genuine as
that of Tam o’ Shanter, and it would seem nothing out of the common
if we should see the twelve signs of the Zodiac saving themselves
from Deucalion’s flood in an arc of the Ecliptic.

Mr. Lowell here read long extracts from the poem, with a
commentary of his own, generally brief, of which we can give only
the following fine passage on Personification.

The truth is, that ideal personifications are commonly little better than
pinchbeck substitutes for imagination. They are a refuge which
unimaginative minds seek from their own sterile imaginativeness.
They stand in the same relation to poetry as wax figures to sculpture.
The more nearly they counterfeit reality, the more unpleasant they
are, and there is always a dejected irresponsibleness about the legs
and a Brattle street air in the boots that is ludicrous. The imagination
gives us no pictures, but the thing itself. It goes out for the moment
to dwell in and inform with its own life the object of its vision—as
Keats says somewhere in one of his letters, “I hop about the gravel
and pick up crumbs in the sparrows.” And so, in personifying, the
imagination must have energy to project its own emotion so as to
see it objectively—just as the disease of the hypochondriac runs
before him in a black dog. Thus it was that the early poets, “who
believed the wonders that they sang,” peopled the forests, floods,
and mountains with real shapes of beauty or terror; and accordingly
in primitive times ecstasy is always attributed to the condition of the
poetic mind. To the great poets these ecstasies are still possible, and
personification had its origin in the tradition of these, and the
endeavor of inferior minds to atone for their own languor by what we
may call historical or reminiscental imagination. Here is indicated the
decline from faith to ritual. Shakspeare has illustrated the true secret
of imaginative personification when he makes the conscience of
Macbeth become external and visible to him in the ghastly shape at
the banquet which he alone can see, and Lady Macbeth’s afterwards
in the blood-stain on her hand. This is the personification of the
creative mind whose thoughts are not images, but things. And this
seems to have been the normal condition of Shakspeare’s genius,
as it is the exceptional one of all other poets. He alone has
embodied in flesh and blood his every thought and fancy and
emotion, his every passion and temptation. Beside him all other
poets seem but the painters and not the makers of men. He sent out
his profound intellect to look at life from every point of view, and
through the eyes of all men and women from the highest to the
lowest. In every one he seems to have tapped it with the knuckles, to
have said sadly, Tinnit, inane est, It rings, it is hollow; and then to
have gone down quietly to wait for death and another world at
Stratford.

As fine an example as any of the prose imagination, of the intellect


acting pictorially, is where Hobbes compares the Papacy to the ghost
of the Roman Empire sitting upon its tomb. This implies a foregone
personification, but the pleasure it gives springs chiefly from our
sense of its historic and intellectual truth. And this subordinate form
of imagination uses typically and metaphorically those forms in which
ecstasy had formerly visibly clothed itself, flesh-and-blooded itself,
so to speak; as where Lord Bacon says that Persecution in the name
of Religion is “to bring down the Holy Ghost, not in the likeness of a
dove, but in the shape of a vulture or a raven.”

After reading more extracts from the poem, Mr. Lowell concluded his
lecture in these words:

Truly it seems to me that I can feel a heart beat all through this old
poem, a manly, trustful, and tender one. There are some men who
have what may be called a vindictive love of Truth—whose love of it,
indeed, seems to be only another form of hatred to their neighbor.
They put crooked pins on the stool of repentance before they invite
the erring to sit down on it. Our brother Langland is plainly not one of
these.

What I especially find to our purpose in Piers Ploughman, as I said


before, is that it defines with tolerable exactness those impulses
which our poetry has received from the Anglo-Saxon as
distinguished from the Anglo-Norman element of our race. It is a
common Yankee proverb that there is a great deal of human nature
in man. I think it especially true of the Anglo-Saxon man. We find in
this poem common sense, tenderness, a love of spiritual goodness
without much sensibility to the merely beautiful, a kind of domestic
feeling of nature and a respect for what is established. But what is
still more noticeable is that man is recognized as man, and that the
conservatism of Langland is predicated upon the well-being of the
people.

It is impossible to revive a dead poem, but it is pleasant, at least, to


throw a memorial flower upon its grave.
LECTURE III
THE METRICAL ROMANCES

(Tuesday Evening, January 16, 1855)

III
Where is the Golden Age? It is fifty years ago to every man and
woman of three-score and ten. I do not doubt that aged Adam
babbled of the superiority of the good old times, and, forgetful in his
enthusiasm of that fatal bite which set the teeth of all his
descendants on edge, told, with a regretful sigh, how much larger
and finer the apples of his youth were than that to which the great-
grandson on his knee was giving a preliminary polish. Meanwhile the
great-grandson sees the good times far in front, a galaxy of golden
pippins whereof he shall pluck and eat as many as he likes without
question. Thus it is that none of us knows when Time is with him, but
the old man sees only his shoulders and that inexorable wallet in
which youth and beauty and strength are borne away as alms for
Oblivion; and the boy beholds but the glowing face and the hands
stretched out full of gifts like those of a St. Nicholas. Thus there is
never any present good; but the juggler, Life, smilingly baffles us all,
making us believe that the vanished ring is under his left hand or his
right, the past or the future, and shows us at last that it was in our
own pocket all the while.

So we may always listen with composure when we hear of Golden


Ages passed away. Burke pronounced the funeral oration of one—of
the age of Chivalry—the period of Metrical Romances—of which I
propose to speak to-night. Mr. Ruskin—himself as true a knight-
errant as ever sat in a demipique saddle, ready to break a lance with
all comers, and resolved that even the windmills and the drovers
shall not go about their business till they have done homage to his
Dulcinea—for the time being joins in the lament. Nay, what do we
learn from the old romances themselves, but that all the heroes were
already dead and buried? Their song also is a threnody, if we listen
rightly. For when did Oliver and Roland live? When Arthur and
Tristem and Lancelot and Caradoc Break-arm? In that Golden Age of
Chivalry which is always past.

Undoubtedly there was a great deal in the institution of Chivalry that


was picturesque; but it is noticeable in countries where society is still
picturesque that dirt and ignorance and tyranny have the chief hand
in making them so. Mr. Fenimore Cooper thought the American
savage picturesque, but if he had lived in a time when it was
necessary that one should take out a policy of insurance on his scalp
or wig before going to bed, he might have seen them in a different
light. The tourist looks up with delight at the eagle sliding in smooth-
winged circles on the icy mountain air, and sparkling back the low
morning sun like a belated star. But what does the lamb think of him?
Let us look at Chivalry a moment from the lamb’s point of view.

It is true that the investiture of the Knight was a religious ceremony,


but this was due to the Church, which in an age of brute force always
maintained the traditions at least of the intellect and conscience. The
vows which the Knights took had as little force as those of god-
parents, who fulfil their spiritual relation by sending a piece of plate
to the god-child. They stood by each other when it was for their
interest to do so, but the only virtue they had any respect for was an
arm stronger than their own. It is hard to say which they preferred to
break—a head, or one of the Ten Commandments. They looked
upon the rich Jew with thirty-two sound teeth in his head as a
providential contrivance, and practised upon him a comprehensive
kind of dental surgery, at once for profit and amusement, and then
put into some chapel a painted window with a Jewish prophet in it for
piety—as if they were the Jewish profits they cared about. They
outraged and robbed their vassals in every conceivable manner,
and, if very religious, made restitution on their death-beds by giving a
part of the plunder (when they could keep it no longer) to have
masses sung for the health of their souls—thus contriving, as they
thought, to be their own heirs in the other world. Individual examples
of heroism are not wanting to show that man is always paramount to
the institutions of his own contriving, so that any institution will yield
itself to the compelling charms of a noble nature. But even were this
not so, yet Sir Philip Sidney, the standard type of the chivalrous,
grew up under other influences. So did Lord Herbert of Cherbury, so
did the incomparable Bayard; and the single fact that is related as a
wonderful thing of Bayard, that, after the storming of Brescia, he
respected the honor of the daughter of a lady in whose house he
was quartered, notwithstanding she was beautiful and in his power,
is of more weight than all the romances in Don Quixote’s library.

But what form is that which rises before us, with features in which
the gentle and forgiving reproach of the woman is lost in the aspiring
power of the martyr?

We know her as she was,

The whitest lily in the shield of France,


With heart of virgin gold,

that bravest and most loyal heart over whose beatings knightly armor
was ever buckled, that saintly shape in which even battle looks
lovely, that life so pure, so inspired, so humble, which stands there
forever to show us how near womanhood ever is to heroism, and
that the human heart is true to an eternal instinct when it paints Faith
and Hope and Charity and Religion with the countenances of
women.

We are told that the sentiment of respect for woman, a sentiment


always remarkable in the Teutonic race, is an inheritance from the
Institution of Chivalry. But womanhood must be dressed in silk and
miniver that chivalry may recognize it. That priceless pearl hidden in
the coarse kirtle of the peasant-girl of Domremy it trampled under its
knightly feet—shall I say?—or swinish hoofs. Poor Joan! The
chivalry of France sold her; the chivalry of England subjected her to
outrages whose burning shame cooled the martyr-fire, and the King
whom she had saved, the very top of French Knighthood, was toying
with Agnes Sorel while the fagots were crackling around the savior of
himself and his kingdom in the square of Rouen! Thank God, that
our unchivalric generation can hack the golden spurs from such
recreant heels! A statue stands now where her ashes were gathered
to be cast into the Seine, but her fittest monument is the little
fountain beneath it, the emblem of her innocence, of her inspiration,
drawn not from court, or castle, or cloister, but from the inscrutable
depths of that old human nature and that heaven common to us all—
an emblem, no less, that the memory of a devoted life is a spring
where all coming times may drink the holy waters of gratitude and
aspiration. I confess that I cannot see clearly that later scaffold in the
Place de la Révolution, through the smoke of this martyr-fire at
Rouen, but it seems to me that, compared with this woman, the
Marie Antoinette, for whose sake Burke lamented the downfall of
chivalry, is only the daughter of a king.

But those old days, whether good or bad, have left behind them a
great body of literature, of which even yet a large part remains
unprinted. To this literature belong the Metrical Romances.
Astonished by the fancy and invention so abundantly displayed by
the writers of these poems, those who have written upon the subject
have set themselves gravely to work to find out what country they
could have got them from. Mr. Warton, following Dr. Warburton,
inclines to assign them to an Oriental origin. Dr. Percy, on the other
hand, asserts a Scandinavian origin; while Ritson, who would have
found it reason enough to think that the sun rose in the West if
Warton or Percy had taken the other side, is positive that they were
wholly French. Perhaps the truth lies somewhere between the
positions of Percy and Ritson. The Norman race, neither French nor
Scandinavian, was a product of the mingled blood of both, and in its
mental characteristics we find the gaiety and lively fancy of the one
tempering what is wild in the energy and gloomy in the imagination
of the other.

We know the exact date of the arrival of the first Metrical Romance in
England. Taillefer, a Norman minstrel, brought it over in his head,
and rode in the front at the battle of Hastings singing the song of
Roland. Taillefer answers precisely the description of a Danish skald,
but he sang in French, and the hero he celebrated was one of the
peers of Charlemagne, who was himself a German.

Taillefer, who well could sing a strain,


Upon a swift horse rode amain
Before the Duke and chanted loud
Of Charlemagne and Roland good,
Of Oliver and vassals brave
Who found at Roncesvalles their grave.

What this song of Roland was it is impossible to say, as the only


copy of it seems to have perished with Taillefer at the battle of
Hastings; but it was probably of the same kind with many of those
which have survived and brought down to us the exploits of Arthur
and his knights.

With regard to a large part of the romances of the Round Table, and
those which grew out of them, it is tolerably certain that, although
written in French, they were made in England.

One of the great charms of the Metrical Romances is the innocent


simplicity with which they commit anachronisms. Perhaps it would be
more exact to call them synchronisms, for, with the most undoubting
faith, they compel all other times to adopt the dress, manners, and
conventionalities of their own. To them there was no one world, nor
ever had been any, except that of Romance. They conferred
retrospective knighthood upon the patriarchs; upon Job, David, and
Solomon. Joseph of Arimathea became Sir Joseph of that ilk. Even
the soldier who pierced the side of Jesus upon the cross was made
into Sir Longinus and represented as running a tilt with our Lord. All
the heroes of the Grecian legend were treated in the same way.
They translated the old time and the old faith into new, and thus
completed the outfit of their own imaginary world, supplying it at a
very cheap rate with a Past and with mythology. And as they
believed the gods and genii of the Pagan ancients to have been evil
spirits who, though undeified, were imperishable in their essence,
they were allowed to emigrate in a body from the old religion into the
new, where they continued to exercise their functions, sometimes
under their former names, but oftener in some disguise. These
unfortunate aliens seem to have lived very much from hand to
mouth, and after the invention of holy water (more terrible to them
than Greek-fire) they must have had rather an uncomfortable time of
it. The giants were received with enthusiasm, and admitted to rights
of citizenship in the land of Romance, where they were allowed to
hold fiefs and castles in consideration of their eminent usefulness in
abducting damsels, and their serving as anvils to the knights, who
sometimes belabored them for three days at a time, the fight ending
at last, not from failure of breath on the part of the combatants but of
the minstrel. As soon as he has enough, or sees that his hearers
have, the head of the unhappy giant becomes loose on his
shoulders.

Another charm of the romances is their entire inconsequentiality. As


soon as we enter this wonderful country the old fetters of cause and
effect drop from our limbs, and we are no longer bound to give a
reason for anything. All things come to pass in that most charming of
ways which children explain by the comprehensive metaphysical
formula—“’cause.” Nothing seems to be premeditated, but a knight
falls in love, or out of it, fights, goes on board enchanted vessels that
carry him to countries laid down on no chart, and all without asking a
question. In truth, it is a delightful kind of impromptu life, such as we
all should like to lead if we could, with nothing set down in the bills
beforehand.

But the most singular peculiarity of Romance-land remains to be


noticed—there are no people in it, that is, no common people. The
lowest rank in life is that of a dwarf. It is true that if a knight loses his
way there will always be a clown or two to set him right. But they
disappear at once, and seem to be wholly phantasmagoric, or, at
best, an expedient rendered necessary by the absence of guide-
posts, and the inability of the cavaliers to read them if there had
been any. There are plenty of Saracens no doubt, but they are more

You might also like