100% found this document useful (1 vote)
167 views

Computer Systems A Programmer s Perspective Randal E. Bryant instant download

The document is about 'Computer Systems: A Programmer's Perspective' by Randal E. Bryant, which covers various aspects of computer systems, including the organization of hardware, the role of operating systems, and the representation of information. It provides insights into how programs are executed and how data is managed within a computer system. The document includes links to download the book and other related resources.

Uploaded by

kamnaajabul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
167 views

Computer Systems A Programmer s Perspective Randal E. Bryant instant download

The document is about 'Computer Systems: A Programmer's Perspective' by Randal E. Bryant, which covers various aspects of computer systems, including the organization of hardware, the role of operating systems, and the representation of information. It provides insights into how programs are executed and how data is managed within a computer system. The document includes links to download the book and other related resources.

Uploaded by

kamnaajabul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Computer Systems A Programmer s Perspective

Randal E. Bryant download

https://ebookultra.com/download/computer-systems-a-programmer-s-
perspective-randal-e-bryant-2/

Explore and download more ebooks or textbooks


at ebookultra.com
We have selected some products that you may be interested in
Click the link to download now or visit ebookultra.com
for more options!.

Computer Systems A Programmer s Perspective Randal E.


Bryant

https://ebookultra.com/download/computer-systems-a-programmer-s-
perspective-randal-e-bryant/

Computer Systems A Programmer s Perspective 2nd Edition


Randal E. Bryant

https://ebookultra.com/download/computer-systems-a-programmer-s-
perspective-2nd-edition-randal-e-bryant/

Computer Design and Computational Defense Systems 1st


Edition Nikos E. Mastorakis

https://ebookultra.com/download/computer-design-and-computational-
defense-systems-1st-edition-nikos-e-mastorakis/

Hardware and computer organization the software


perspective Arnold S. Berger

https://ebookultra.com/download/hardware-and-computer-organization-
the-software-perspective-arnold-s-berger/
Eating Disorders A Parent s Guide Ra Bryant-Waugh

https://ebookultra.com/download/eating-disorders-a-parent-s-guide-ra-
bryant-waugh/

Excel 2007 VBA Programmer s Reference Programmer to


Programmer 1st Edition John Green

https://ebookultra.com/download/excel-2007-vba-programmer-s-reference-
programmer-to-programmer-1st-edition-john-green/

Introduction to Embedded Systems A Cyber Physical Systems


Approach 1ST Edition E. A. Lee And S. A. Seshia

https://ebookultra.com/download/introduction-to-embedded-systems-a-
cyber-physical-systems-approach-1st-edition-e-a-lee-and-s-a-seshia/

Linear Systems and Control An Operator Perspective 1st


Edition Martin J. Corless & Arthur E. Frazho

https://ebookultra.com/download/linear-systems-and-control-an-
operator-perspective-1st-edition-martin-j-corless-arthur-e-frazho/

Flickr Mashups Programmer to Programmer 1st Edition David


A. Wilkinson

https://ebookultra.com/download/flickr-mashups-programmer-to-
programmer-1st-edition-david-a-wilkinson/
Computer Systems A Programmer s Perspective Randal
E. Bryant Digital Instant Download
Author(s): Randal E. Bryant, David R. O'Hallaron
ISBN(s): 9780130340740, 013034074X
Edition: US ed
File Details: PDF, 4.81 MB
Year: 2002
Language: english
Contents

Preface i

1 Introduction 1
1.1 Information is Bits in Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Programs are Translated by Other Programs into Different Forms . . . . . . . . . . . . . . . 3
1.3 It Pays to Understand How Compilation Systems Work . . . . . . . . . . . . . . . . . . . . 4
1.4 Processors Read and Interpret Instructions Stored in Memory . . . . . . . . . . . . . . . . . 5
1.4.1 Hardware Organization of a System . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 Running the hello Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Caches Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 Storage Devices Form a Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.7 The Operating System Manages the Hardware . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7.1 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.7.2 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.3 Virtual Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.4 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.8 Systems Communicate With Other Systems Using Networks . . . . . . . . . . . . . . . . . 16
1.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

I Program Structure and Execution 19

2 Representing and Manipulating Information 21


2.1 Information Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.1.1 Hexadecimal Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1.2 Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3
4 CONTENTS

2.1.3 Data Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25


2.1.4 Addressing and Byte Ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1.5 Representing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1.6 Representing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.1.7 Boolean Algebras and Rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.1.8 Bit-Level Operations in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.1.9 Logical Operations in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.1.10 Shift Operations in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.2 Integer Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.2.1 Integral Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.2.2 Unsigned and Two’s Complement Encodings . . . . . . . . . . . . . . . . . . . . . 41
2.2.3 Conversions Between Signed and Unsigned . . . . . . . . . . . . . . . . . . . . . . 45
2.2.4 Signed vs. Unsigned in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.2.5 Expanding the Bit Representation of a Number . . . . . . . . . . . . . . . . . . . . 49
2.2.6 Truncating Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.2.7 Advice on Signed vs. Unsigned . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.3 Integer Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.3.1 Unsigned Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.3.2 Two’s Complement Addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.3.3 Two’s Complement Negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2.3.4 Unsigned Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.3.5 Two’s Complement Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.3.6 Multiplying by Powers of Two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.3.7 Dividing by Powers of Two . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.4 Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.4.1 Fractional Binary Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.4.2 IEEE Floating-Point Representation . . . . . . . . . . . . . . . . . . . . . . . . . . 69
2.4.3 Example Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.4.4 Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
2.4.5 Floating-Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
2.4.6 Floating Point in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
CONTENTS 5

3 Machine-Level Representation of C Programs 89


3.1 A Historical Perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.2 Program Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
3.2.1 Machine-Level Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.2.2 Code Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3.2.3 A Note on Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
3.3 Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
3.4 Accessing Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.4.1 Operand Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
3.4.2 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.4.3 Data Movement Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.5 Arithmetic and Logical Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.5.1 Load Effective Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.5.2 Unary and Binary Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.5.3 Shift Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.5.4 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.5.5 Special Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.6 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.6.1 Condition Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
3.6.2 Accessing the Condition Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
3.6.3 Jump Instructions and their Encodings . . . . . . . . . . . . . . . . . . . . . . . . . 114
3.6.4 Translating Conditional Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.6.5 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.6.6 Switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
3.7 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3.7.1 Stack Frame Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3.7.2 Transferring Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3.7.3 Register Usage Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
3.7.4 Procedure Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
3.7.5 Recursive Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
3.8 Array Allocation and Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
3.8.1 Basic Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3.8.2 Pointer Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
6 CONTENTS

3.8.3 Arrays and Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145


3.8.4 Nested Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
3.8.5 Fixed Size Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
3.8.6 Dynamically Allocated Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
3.9 Heterogeneous Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.9.1 Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.9.2 Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
3.10 Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.11 Putting it Together: Understanding Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.12 Life in the Real World: Using the G DB Debugger . . . . . . . . . . . . . . . . . . . . . . . 165
3.13 Out-of-Bounds Memory References and Buffer Overflow . . . . . . . . . . . . . . . . . . . 167
3.14 *Floating-Point Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.14.1 Floating-Point Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.14.2 Extended-Precision Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
3.14.3 Stack Evaluation of Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
3.14.4 Floating-Point Data Movement and Conversion Operations . . . . . . . . . . . . . . 179
3.14.5 Floating-Point Arithmetic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . 181
3.14.6 Using Floating Point in Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . 183
3.14.7 Testing and Comparing Floating-Point Values . . . . . . . . . . . . . . . . . . . . . 184
3.15 *Embedding Assembly Code in C Programs . . . . . . . . . . . . . . . . . . . . . . . . . . 186
3.15.1 Basic Inline Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
3.15.2 Extended Form of asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

4 Processor Architecture 201

5 Optimizing Program Performance 203


5.1 Capabilities and Limitations of Optimizing Compilers . . . . . . . . . . . . . . . . . . . . . 204
5.2 Expressing Program Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
5.3 Program Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
5.4 Eliminating Loop Inefficiencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
5.5 Reducing Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
5.6 Eliminating Unneeded Memory References . . . . . . . . . . . . . . . . . . . . . . . . . . 218
CONTENTS 7

5.7 Understanding Modern Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220


5.7.1 Overall Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
5.7.2 Functional Unit Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5.7.3 A Closer Look at Processor Operation . . . . . . . . . . . . . . . . . . . . . . . . . 225
5.8 Reducing Loop Overhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
5.9 Converting to Pointer Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
5.10 Enhancing Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
5.10.1 Loop Splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
5.10.2 Register Spilling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
5.10.3 Limits to Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
5.11 Putting it Together: Summary of Results for Optimizing Combining Code . . . . . . . . . . 247
5.11.1 Floating-Point Performance Anomaly . . . . . . . . . . . . . . . . . . . . . . . . . 248
5.11.2 Changing Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
5.12 Branch Prediction and Misprediction Penalties . . . . . . . . . . . . . . . . . . . . . . . . . 249
5.13 Understanding Memory Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
5.13.1 Load Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
5.13.2 Store Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
5.14 Life in the Real World: Performance Improvement Techniques . . . . . . . . . . . . . . . . 260
5.15 Identifying and Eliminating Performance Bottlenecks . . . . . . . . . . . . . . . . . . . . . 261
5.15.1 Program Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
5.15.2 Using a Profiler to Guide Optimization . . . . . . . . . . . . . . . . . . . . . . . . 263
5.15.3 Amdahl’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
5.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

6 The Memory Hierarchy 275


6.1 Storage Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
6.1.1 Random-Access Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
6.1.2 Disk Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
6.1.3 Storage Technology Trends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
6.2 Locality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
6.2.1 Locality of References to Program Data . . . . . . . . . . . . . . . . . . . . . . . . 295
6.2.2 Locality of Instruction Fetches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
6.2.3 Summary of Locality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
8 CONTENTS

6.3 The Memory Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298


6.3.1 Caching in the Memory Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6.3.2 Summary of Memory Hierarchy Concepts . . . . . . . . . . . . . . . . . . . . . . . 303
6.4 Cache Memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
6.4.1 Generic Cache Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . . 305
6.4.2 Direct-Mapped Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.4.3 Set Associative Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
6.4.4 Fully Associative Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
6.4.5 Issues with Writes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
6.4.6 Instruction Caches and Unified Caches . . . . . . . . . . . . . . . . . . . . . . . . 319
6.4.7 Performance Impact of Cache Parameters . . . . . . . . . . . . . . . . . . . . . . . 320
6.5 Writing Cache-friendly Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
6.6 Putting it Together: The Impact of Caches on Program Performance . . . . . . . . . . . . . 327
6.6.1 The Memory Mountain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
6.6.2 Rearranging Loops to Increase Spatial Locality . . . . . . . . . . . . . . . . . . . . 331
6.6.3 Using Blocking to Increase Temporal Locality . . . . . . . . . . . . . . . . . . . . 335
6.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

II Running Programs on a System 347

7 Linking 349
7.1 Compiler Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
7.2 Static Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
7.3 Object Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
7.4 Relocatable Object Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
7.5 Symbols and Symbol Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
7.6 Symbol Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
7.6.1 How Linkers Resolve Multiply-Defined Global Symbols . . . . . . . . . . . . . . . 358
7.6.2 Linking with Static Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
7.6.3 How Linkers Use Static Libraries to Resolve References . . . . . . . . . . . . . . . 364
7.7 Relocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
7.7.1 Relocation Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
7.7.2 Relocating Symbol References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
CONTENTS 9

7.8 Executable Object Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371


7.9 Loading Executable Object Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
7.10 Dynamic Linking with Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
7.11 Loading and Linking Shared Libraries from Applications . . . . . . . . . . . . . . . . . . . 376
7.12 *Position-Independent Code (PIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
7.13 Tools for Manipulating Object Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
7.14 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

8 Exceptional Control Flow 391


8.1 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
8.1.1 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
8.1.2 Classes of Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
8.1.3 Exceptions in Intel Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
8.2 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
8.2.1 Logical Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
8.2.2 Private Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
8.2.3 User and Kernel Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
8.2.4 Context Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
8.3 System Calls and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
8.4 Process Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
8.4.1 Obtaining Process ID’s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
8.4.2 Creating and Terminating Processes . . . . . . . . . . . . . . . . . . . . . . . . . . 404
8.4.3 Reaping Child Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
8.4.4 Putting Processes to Sleep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
8.4.5 Loading and Running Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
8.4.6 Using fork and execve to Run Programs . . . . . . . . . . . . . . . . . . . . . . 418
8.5 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
8.5.1 Signal Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
8.5.2 Sending Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
8.5.3 Receiving Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
8.5.4 Signal Handling Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
8.5.5 Portable Signal Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
8.6 Nonlocal Jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
10 CONTENTS

8.7 Tools for Manipulating Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441


8.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

9 Measuring Program Execution Time 449


9.1 The Flow of Time on a Computer System . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
9.1.1 Process Scheduling and Timer Interrupts . . . . . . . . . . . . . . . . . . . . . . . 451
9.1.2 Time from an Application Program’s Perspective . . . . . . . . . . . . . . . . . . . 452
9.2 Measuring Time by Interval Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
9.2.1 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
9.2.2 Reading the Process Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
9.2.3 Accuracy of Process Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
9.3 Cycle Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
9.3.1 IA32 Cycle Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
9.4 Measuring Program Execution Time with Cycle Counters . . . . . . . . . . . . . . . . . . . 460
9.4.1 The Effects of Context Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
9.4.2 Caching and Other Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
9.4.3 The K -Best Measurement Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
9.5 Time-of-Day Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
9.6 Putting it Together: An Experimental Protocol . . . . . . . . . . . . . . . . . . . . . . . . . 478
9.7 Looking into the Future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
9.8 Life in the Real World: An Implementation of the K -Best Measurement Scheme . . . . . . 480
9.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

10 Virtual Memory 485


10.1 Physical and Virtual Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
10.2 Address Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
10.3 VM as a Tool for Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
10.3.1 DRAM Cache Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
10.3.2 Page Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
10.3.3 Page Hits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
10.3.4 Page Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
10.3.5 Allocating Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
10.3.6 Locality to the Rescue Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
CONTENTS 11

10.4 VM as a Tool for Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493


10.4.1 Simplifying Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
10.4.2 Simplifying Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
10.4.3 Simplifying Memory Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
10.4.4 Simplifying Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
10.5 VM as a Tool for Memory Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
10.6 Address Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
10.6.1 Integrating Caches and VM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
10.6.2 Speeding up Address Translation with a TLB . . . . . . . . . . . . . . . . . . . . . 500
10.6.3 Multi-level Page Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
10.6.4 Putting it Together: End-to-end Address Translation . . . . . . . . . . . . . . . . . 504
10.7 Case Study: The Pentium/Linux Memory System . . . . . . . . . . . . . . . . . . . . . . . 508
10.7.1 Pentium Address Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
10.7.2 Linux Virtual Memory System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
10.8 Memory Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
10.8.1 Shared Objects Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
10.8.2 The fork Function Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
10.8.3 The execve Function Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
10.8.4 User-level Memory Mapping with the mmap Function . . . . . . . . . . . . . . . . 520
10.9 Dynamic Memory Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
10.9.1 The malloc and free Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
10.9.2 Why Dynamic Memory Allocation? . . . . . . . . . . . . . . . . . . . . . . . . . . 524
10.9.3 Allocator Requirements and Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
10.9.4 Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
10.9.5 Implementation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
10.9.6 Implicit Free Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
10.9.7 Placing Allocated Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
10.9.8 Splitting Free Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
10.9.9 Getting Additional Heap Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
10.9.10 Coalescing Free Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
10.9.11 Coalescing with Boundary Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
10.9.12 Putting it Together: Implementing a Simple Allocator . . . . . . . . . . . . . . . . . 535
10.9.13 Explicit Free Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
12 CONTENTS

10.9.14 Segregated Free Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544


10.10Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
10.10.1 Garbage Collector Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
10.10.2 Mark&Sweep Garbage Collectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
10.10.3 Conservative Mark&Sweep for C Programs . . . . . . . . . . . . . . . . . . . . . . 550
10.11Common Memory-related Bugs in C Programs . . . . . . . . . . . . . . . . . . . . . . . . 551
10.11.1 Dereferencing Bad Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
10.11.2 Reading Uninitialized Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
10.11.3 Allowing Stack Buffer Overflows . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
10.11.4 Assuming that Pointers and the Objects they Point to Are the Same Size . . . . . . . 552
10.11.5 Making Off-by-one Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
10.11.6 Referencing a Pointer Instead of the Object it Points to . . . . . . . . . . . . . . . . 553
10.11.7 Misunderstanding Pointer Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . 554
10.11.8 Referencing Non-existent Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 554
10.11.9 Referencing Data in Free Heap Blocks . . . . . . . . . . . . . . . . . . . . . . . . . 555
10.11.10Introducing Memory Leaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
10.12Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556

III Interaction and Communication Between Programs 561

11 Concurrent Programming with Threads 563


11.1 Basic Thread Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
11.2 Thread Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
11.2.1 Creating Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
11.2.2 Terminating Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
11.2.3 Reaping Terminated Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
11.2.4 Detaching Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
11.3 Shared Variables in Threaded Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
11.3.1 Threads Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
11.3.2 Mapping Variables to Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
11.3.3 Shared Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
11.4 Synchronizing Threads with Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
11.4.1 Sequential Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
CONTENTS 13

11.4.2 Progress Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576


11.4.3 Protecting Shared Variables with Semaphores . . . . . . . . . . . . . . . . . . . . . 579
11.4.4 Posix Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
11.4.5 Signaling With Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
11.5 Synchronizing Threads with Mutex and Condition Variables . . . . . . . . . . . . . . . . . 583
11.5.1 Mutex Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
11.5.2 Condition Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
11.5.3 Barrier Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
11.5.4 Timeout Waiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
11.6 Thread-safe and Reentrant Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
11.6.1 Reentrant Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
11.6.2 Thread-safe Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
11.7 Other Synchronization Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
11.7.1 Races . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
11.7.2 Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
11.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

12 Network Programming 605


12.1 Client-Server Programming Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
12.2 Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606
12.3 The Global IP Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
12.3.1 IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612
12.3.2 Internet Domain Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
12.3.3 Internet Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
12.4 Unix file I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
12.4.1 The read and write Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
12.4.2 Robust File I/O With the readn and writen Functions. . . . . . . . . . . . . . . 621
12.4.3 Robust Input of Text Lines Using the readline Function . . . . . . . . . . . . . . 623
12.4.4 The stat Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
12.4.5 The dup2 Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
12.4.6 The close Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
12.4.7 Other Unix I/O Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
12.4.8 Unix I/O vs. Standard I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
14 CONTENTS

12.5 The Sockets Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629


12.5.1 Socket Address Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
12.5.2 The socket Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
12.5.3 The connect Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
12.5.4 The bind Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
12.5.5 The listen Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
12.5.6 The accept Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
12.5.7 Example Echo Client and Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
12.6 Concurrent Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
12.6.1 Concurrent Servers Based on Processes . . . . . . . . . . . . . . . . . . . . . . . . 638
12.6.2 Concurrent Servers Based on Threads . . . . . . . . . . . . . . . . . . . . . . . . . 640
12.7 Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
12.7.1 Web Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
12.7.2 Web Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
12.7.3 HTTP Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648
12.7.4 Serving Dynamic Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
12.8 Putting it Together: The T INY Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
12.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662

A Error handling 665


A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665
A.2 Error handling in Unix systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
A.3 Error-handling wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
A.4 The csapp.h header file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
A.5 The csapp.c source file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675

B Solutions to Practice Problems 691


B.1 Intro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
B.2 Representing and Manipulating Information . . . . . . . . . . . . . . . . . . . . . . . . . . 691
B.3 Machine Level Representation of C Programs . . . . . . . . . . . . . . . . . . . . . . . . . 700
B.4 Processor Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
B.5 Optimizing Program Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
B.6 The Memory Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
CONTENTS 15

B.7 Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723


B.8 Exceptional Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
B.9 Measuring Program Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
B.10 Virtual Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
B.11 Concurrent Programming with Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
B.12 Network Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
16 CONTENTS
Random documents with unrelated
content Scribd suggests to you:
slipped into the room and made us a low bow; he was the
Burgomaster, come to pay his respects and to inquire if we had all we
wanted. While entirely appreciating the kindness that prompted his visit
we could willingly have dispensed with it, on account of the immense
exertion required to express ourselves in Spanish at all, and the
impossibility of doing so as we should wish. We gathered that he was
placing himself and all he possessed at our disposal, and we did our
best to rise to the occasion; but sentiments of gratitude are sadly
lamed by a limited vocabulary. We tried to improve our position by
asking if he could speak French, and expressing our disappointment
when he negatived the question. The interview was punctuated by
rather painful silences—and it was with a certain sense of relief that we
saw our friendly visitor bow himself out again on being assured there
was nothing he could do for us.
All that night a terrific storm raged. Mingled with the rattling of hail
and the crash of thunder came the sound of the Sereno hammering at
the house door to wake the fondista, and shortly afterwards we heard
the latter come upstairs and pound lustily upon the door of an
adjoining bedroom; some señor had to be called to catch the diligence,
which—according to Spanish custom—leaves Andraitx at the
extraordinary hour of two o’clock in the morning.
By the time we had finished breakfast the sun was shining hotly once
more, and we were able to start for San Telmo. Seated in a small
carreta—a very light skeleton cart on two wheels, with rush mats
spread over the bars of the bottom and sides—we set out at a foot’s
pace to visit the old castle on the coast, an hour and a half distant. For
a mile or so one ascends by a very steep mountain road, but after
crossing the col this road deteriorates into the roughest of cart tracks,
winding down to the sea through a valley of pine-trees, olives, and
carobs.
A country road in Majorca may mean anything—from a tract of
bedrock scattered with loose stones of any size, to a soft, uneven hill-
path, barely wide enough for a wheeled vehicle to pass. Short of
coming to actual steps, a carreta is expected to follow anywhere where
a pony can obtain a footing, and many a time did the bumps and
lurches to which we were subjected recall George Sand’s driving
experiences in the year 1838.
Speaking of what is now one of the finest roads in the island she
narrates in lively French how in her day the journey was perilously
accomplished—“with one wheel on the mountain and one in the
ravine.... The jolting is indescribable ... yet however frightful a
concussion the driver receives, he sings all the time in a loud voice—
only breaking off to bestow curses upon his horse if the animal
hesitates for an instant before plunging down some precipice or
climbing some rock wall.... For it is thus one proceeds—ravines,
torrents, quagmires, ditches, hedges, all present themselves in vain—
one does not stop for so little. Besides, it is all part of the road; at first
you think you must be steeplechasing for a wager, and you ask your
driver what possesses him. This is the road, he replies. But that river?
It is the road. And this deep pit? The road. And that bush also? Always
the road.... A la bonne heure! And all that remains for you to do is to
commend your soul to God and to contemplate the landscape, while
awaiting death or a miracle.”
Descending from the carreta shortly after starting, to lighten the load
of the floundering pony, I had at first persuaded the stout proprietor to
follow my example; but within a very short time he had climbed in
again, observing with a loud gasp that the way was long. It was not
the first time he had been to San Telmo; only a year ago he had driven
two English ladies there, and they too had had a camera, and on the
way it fell out of the cart and was lost. To this day he could remember
their lamentable cries of “La máquina, la máquina!” But five days later
it was picked up by an old man, who thought it was a bomb and
carried it home very cautiously. The ladies were very pleased—oh yes,
they gave him more than a day’s wages for it.
The little castle of San Telmo was built in the sixteenth century for
the protection of Andraitx. It stands on a rocky prominence by the
seashore, and is in good preservation, its barrel-vaulted dining hall
serving as a workshop for the old man who lives there. From the flat
roof of the tower, where rusty cannon still occupy the embrasures, one
looks down upon a pretty beach, where long green waves, lit up by the
sun, break gently upon the sand, and great conch shells are sometimes
found amongst the foam fringes of the surf. Some three hundred yards
out from the shore is the low turtle-backed rock Pentaleu, where the
Conqueror first set foot on quitting his storm-tossed galley; and
screening the northern side of the little bay are the bare grey flanks—
dreaded by sailors—of the Dragonéra, Majorca’s westernmost outpost.
A lighthouse occupies the knife-like ridge of the summit, and cutting
along through the Freu—the narrow strait between the island rock and
the mainland—comes a little white steamer, the Barcelona boat,
bringing a welcome cargo of mails after a silence that has lasted more
than a week.
The following morning, March 29th, we set out for Estallenchs, our
cavalcade consisting of one riding mule and a sturdy donkey to carry
the luggage. No expedition could have offered a greater contrast to our
tour of the preceding week than did this journey across the mountains.
On the southern plain a whole day’s march of thirty miles is
accomplished in a morning’s drive; in the Sierra we take four hours to
cover a distance of twelve miles. Up and down among the hills winds
the mule track; now we are high above the lapis lazuli sea, on a
mountain path knee deep in palmetto fans and the red-velvet flower of
lentiscus bushes; now we descend to a torrent bed hemmed in by
great grey cliffs scarred with red scarps where part of the hillside has
broken off and poured like an avalanche into the bed of the valley. Now
we enter the pine woods where the white allium and many orchises
grow, and the air is fragrant with rosemary and gorse. Further on we
come to a winding rock staircase cut in the face of the cliff, down
which, our guide tells us, it is not safe to ride; the only surprising thing
is that any animal except a goat should be expected to descend it; and
here our baggage donkey distinguished himself by slipping down and
lying motionless, but quite unhurt, till he was unloaded and dragged on
to his legs again.
A rough cart track winds for some way into these lonely hills, and we
meet timber carts descending with loads of fir-trees, the mules
stumbling and sliding on their haunches down the steep hillside—the
heavy two-wheeled carts, with powerful brakes on, crashing and jolting
behind them over boulders and tree-stumps.
As we approach human habitations again, traces of cultivation once
more appear; small terraces are levelled on the mountain side and
planted with almond-trees, from which our men snatch handfuls of
young milky nuts in passing—a universal habit that has given rise to
the sarcastic proverb, “The laden almond-tree by the wayside is sure to
be bitter.” At last, after a long and fatiguing descent by shallow paved
steps, we come in sight of Estallenchs—a pretty village nestling in a
fold of the hills, backed by cliffs, grey peaks of sun and shadow; in
front a valley opening down to the sea, with hill slopes clothed in
almond, olive, and fir.
The inn is a very humble building, and does not even entitle itself a
fonda. The master of the house was absent, and the old woman left in
charge spoke no Spanish; we spoke no Majorcan, and by way of
facilitating conversation she suddenly sent an urgent message to the
village doctor, who arrived post haste, thinking that some accident had
befallen the English señoras. Somewhat dashed at finding us both
uninjured and in good health, he yet conversed with us very pleasantly
in our attic chamber, offered to show us the place, translated various
requests for us, and before leaving ordered our dinner. Thanks to his
ministrations we lacked for nothing that night, the only hitch occurring
at bedtime, when our best efforts to obtain candles resulted in a dish
of olives being set before us.
“... the pretty village of Estallenchs, backed by great grey cliffs,
and with a valley in front opening down to the sea.”
(page 74)
“The light streaming through the great outer door revealed the
usual spotless interior of a Majorcan house.”
(page 75)
The following morning a cheerful jingle of bells announces the arrival
of our good Pépé and the victoria; the approach to the inn being too
narrow for a carriage to pass, our belongings are carried up to the
main road and there bestowed upon the box. Village dames look on
from their doorways and nod affably, and one of them invited us to
come in while waiting for the carriage to be packed, and took the
deepest interest in our proceedings when we proposed photographing
her room—only regretful that her floor was not yet covered with the
tiles she showed us stacked in readiness. The only light streamed
through the great stone archway of the outer door, and revealed the
usual spotless interior of a Majorcan house, the walls snowy with
repeated coats of whitewash. Good string-seated chairs and stools
were ranged neatly round the room, and on the shelves stood the
graceful water-jars in daily use among the people. Boxwood spoons
and forks hung in a rack by the chimney corner, and over a clear fire of
almond-shells upon the hearth bubbled a pot of bean soup; nothing
would content the good housewife but that we should taste it—and
most excellent it was. Everything about the place was tidy and
exquisitely clean.
You might search in Majorca for a long time I fancy before you would
find a slattern.
The scale of wages in the island is low—a labourer rarely earning
more than eighteen pence a day; but there is every sign of general
prosperity. The necessaries of life are very cheap, and a well-built stone
house can be obtained in country villages at a rental of from two to
three pounds a year.
The drive from Estallenchs to Bañalbufár is—from the point of view
of scenery—one of the finest in the island; high above the sea runs the
road, following every curve of the rugged coast; dark, fir-crowned cliffs
tower overhead, and mountain ranges in splendid perspective jut out
into the blue Mediterranean. Headland upon headland, point upon
point—each intervening bay outlined with a semicircle of snow-white
foam—they stretch back to where the faint blue battering-ram of the
Dragonéra is still dimly visible in the haze of distance.
Perched on a rock pinnacle above the sea stand the yellow walls of
an old watch tower; these towers, or ataláyas as they are called, were
in olden days tenanted by coastguards, who from their lofty eyries
watched the sea and gave the alarm to the countryside when any
suspicious sail appeared on the horizon; a system of smoke-signals was
in use by which the movements of a hostile fleet could be
communicated to all the other ataláyas along the coast and to the
inhabitants of the interior.
Bañalbufár is a small village built upon a mountain slope high above
the sea, chiefly noticeable for the marvellous terracing of the
surrounding hillsides; the terraces are so narrow and the walls so high
that seen from below the effect is that of an unbroken stone wall
several hundred feet in height, while from a little distance they
resemble a gigantic flight of curved steps or an inverted amphitheatre
upon the hillside. Vines and tomatoes are largely grown by the
industrious inhabitants.
Down by the sea, in the cavernous recesses of overhanging rocks,
are some curious corn mills, to which one descends by a steep paved
path, the tiny mountain stream that works the mills raging and sluicing
alongside in a polished aqueduct at such prodigious speed that upon
touching the water your hand receives a smart blow.
Here upon a small headland below the village we ate our luncheon,
among clumps of purple stock and bushes of bright green spurge—
devouring the while a week’s budget of letters that Pépé had brought
out with him; after which we rejoined our carriage and began the long
ascent of the Col that lay between us and Palma. Like a snake does the
white road wind in loops up the mountain side; the Pinus maritima
clothes the hill slopes to the very summit, but rarely attains an even
respectable size. In this respect Majorca differs strikingly from Corsica,
where grand forests of Laricio pine flourish in the rockiest of soils.
Natural timber is indeed a feature entirely lacking in the greater part of
Majorca, owing to the fact that whenever it is in any way possible to
utilise the ground it is devoted to the more profitable culture of the
olive and almond.
Leaving the mountains behind us we presently pass Esporlás, with its
rushing stream bordered by Lombardy poplars, and its great cloth
factory, where hanks of dyed cotton are hanging out to dry; and soon
after reaching Establiments—a trim and prosperous townlet nine
kilometres from Palma—the rain comes down in torrents. We meet
flocks of drenched sheep, and tilted country carts returning from
market, each carter fast asleep inside, with his head on a pile of sacks
and a blanket drawn up to his chin, leaving all responsibility to the
sagacious mule who steps aside to let us pass. The wheat fields are
dripping, the wet air is heavy with the scent of flowering may, and
Palma itself is spanned by a bright rainbow. Let it rain! we are back in
comfortable quarters once more!

On the 2nd of April we went to spend a few days at Sollér—the one


inevitable expedition for all visitors to Palma. By the most direct route
the drive only occupies three hours, but it is best to make a détour by
way of Valldemósa and Miramár, so as to include the beautiful scenery
of the north coast.
Long and straight and flat is the road to Valldemósa, the cornfields
on either side decked out with blue borage, gladiolus, and pink allium,
and bordered with a fringe of flaring yellow daisies—the kind known in
English gardens as annual chrysanthemums. A brilliant touch of colour
is given by a row of bright vermilion flower-pots, set out on the snow-
white parapet of a country house; but actual flower gardens are as
lacking among the homesteads of Majorca as among those of most
southern lands—and the peasants would no doubt marvel greatly at
the sentiment which induces an English cottager to allot so much
valuable space to flowers when he might devote it to the utilitarian
onion or the practical potato.
A couple of hours’ drive brings one to the foot of the mountains, and
passing through a fine gorge the road ascends to the village of
Valldemósa, perched upon a saddle among the hills. It was here that in
the sixteenth century Santa Catalina was born—the pious maiden who
on her walks used the leaves of the olive and lentisk as rosaries, and
who from her cell heard mass being celebrated in Palma Cathedral, ten
miles distant; but Valldemósa’s chief claim to fame lies in her great
Carthusian monastery, a huge yellow pile occupying the ridge above
the village. Originating as the summer palace of the Moorish rulers of
Majorca, the great building was subsequently used as a residence by
the kings of Aragon, and it was not till the year 1400 that it fell into the
hands of the monks; fortified, restored, and added to at various times,
the monastery eventually covered an enormous area of ground, and
sufficient still remains to amaze us at the lavish style in which twelve
Carthusian friars and their Father Superior were housed.
When the monastery was suppressed in 1835, the Spanish
government made over the newer wing of the building to private
persons, and nine Majorcan families occupy the monks’ old quarters to
this day. Very charming are these monastic residences, entered from
the cool, whitewashed cloisters; each set of rooms is quite secluded
from the rest, and each has its small terrace garden to the south,
where lemon-trees bask in the sunshine, screened by the high walls
that divide each monk’s territory from that of his neighbour on either
side. From the low parapet in front one looks out over a steep declivity
of orange groves and ranges of hills stretching down to the gorge—the
gate of the plains.
It was in one of these apartments that George Sand passed the
winter when she visited the island with her two children in the year
1838, accompanied by the invalid Chopin. The accommodation
provided for one Carthusian friar—three good-sized rooms and a
kitchen on the ground floor, with as many bedrooms above stairs—
afforded ample living room for the party of four; but the winter proved
bitterly cold, and all the comforts of a northern home were lacking in
an island where open fireplaces are unknown, and a brazier filled with
charcoal is the only means of warming a room. At great expense an
iron stove was brought up to Valldemósa and installed in one of the
rooms, where it smelt abominably. In other matters the unfortunate
strangers were no happier; the grand piano—imported from France—
gave such endless trouble at the Palma customs that they would
willingly have had it sunk in the harbour—but even that was not
permitted. It was only after protracted wrangling that it was finally
liberated upon the payment of four hundred francs.
“It was here that George Sand passed the winter when she
visited the island with her two children in 1838, accompanied by
the invalid Chopin.”
(page 80)
“The mountain ranges stretch back in splendid perspective to
where the faint blue battering-ram of the Dragonéra is dimly
visible in the distance.”
(page 76)
The attitude of the Valldemósans too was anything but pleasant or
conciliatory to the French exiles; the expulsion of the monks was too
recent for them to have become reconciled to the occupation of the
monastery by lay residents, and they looked with intense suspicion on
these foreigners who never came to church and who scandalised
society by allowing a little girl of nine to roam the country attired in
rational costume.
There were doubtless faults on both sides; if the peasants regarded
George Sand as a heathen, she looked upon them as uncharitable and
bigoted barbarians, and she contrasts the result of their so-called
religion with the abomination of desolation of philosophy in which—as
she ironically remarks—her own children were brought up.
Life in Majorca seems to have offered few attractions to the foreigner
in those days; setting aside the difficulties of transit—difficulties
rendered doubly trying in the case of an invalid—the discomfort of the
pig-boat by which one came to Palma, and the shocking state of the
roads, to which I have previously alluded—setting all this aside, the
very character of the islanders seems to have been radically different
when George Sand sojourned amongst them from what it is now.
According to her, the Majorcans were dirty and impertinent; they
cheated one shamelessly at every turn; they were calculating, selfish,
and utterly heartless where their own interest was concerned; letters of
recommendation to twenty Palma residents would hardly suffice to
prevent a stranger from wandering homeless about the town on arrival;
and if any luckless foreigner presumed to complain of the treatment he
received, or so much as ventured to express disapproval at the
presence of scorpions in his soup, a torrent of indignation and
contempt descended on his head.
Now our own impressions of the Majorcans differed so wholly from
the above description that it is difficult to realise that the writer was
referring to the same people. Our experience of the island was,
however, necessarily a brief and superficial one—and though I have
endeavoured faithfully to record all that befell us on our travels I am
open to the charge of having taken too couleur-de-rose a view, or—in
the more pithy Minorcan phrase—of having unconsciously resembled
“the ass of Moro, who was enchanted with everything.”
I therefore quote the following words written by one not open to this
charge—the Austrian Archduke Louis Salvator, who for more than
twenty years made the island his home, who travelled about among
the peasants, and who probably knows the island and its inhabitants
more intimately than do most of the natives themselves:—
“The Majorcans,” he writes, “are gentle, cheerful, open-hearted,
compassionate, and charitable to the poor; faithful in friendship, and
extremely attached to their wives and children; very hospitable, like all
the Balearic peoples—this applies to rich and poor alike, who all heap
kindness upon the stranger and entertain him with their best.”
How to reconcile this opinion with that of George Sand I do not know
—for it is not usual for the racial characteristics of an island people to
alter so completely in fifty years. I can only imagine that the French
authoress must have arrived in Majorca at an inauspicious moment;
that she unintentionally roused the animosity of her neighbours, and
that she may have been actually unlucky in the people with whom she
came in contact; while anxiety over the condition of her sick friend did
not improve her temper. It must not be supposed, however, that her
winter at Valldemósa was one long Jeremiad; she thoroughly enjoyed
the beauty of the scenery and the flowers, and her vivid imagination,
her spirit, and her sense of humour carried her through trials that
would have depressed many another person.
An apology is due to her memory for the deliberate charge brought
against her in Murray’s guide-book of having damaged a certain
“priceless historical document” during her stay in the island. The
document in question is a curious illuminated map of Europe and the
north coast of Africa, made for Amerigo Vespucci in the year 1439 by a
Majorcan draughtsman; and George Sand is most unjustly held up to
the reprobation of all future travellers as having obtained permission to
copy this map, and as having upset her inkpot over it.
That an inkpot was upset over it she herself records in dramatic
narration, but her account of the affair goes to show that she had
neither part nor lot in bringing about the accident; her hair stands on
end with horror as she recalls the scene....
She was being shown the library collected by Cardinal Despuig, uncle
to the then Count of Montenegro, when the house-chaplain
volunteered to show her the precious map—the gem of the collection.
Spreading it on a table he unrolled the beautiful illuminated parchment
—whereon large cities share the Sahara with equally large savages
mounted on camels; but the vellum was reluctant to remain flat, seeing
which, a servant placed a full inkstand upon a corner of the map to
keep it open. But alas! its weight was insufficient! The scroll gave a
crack—a leap—and lo! it was again rolled up, with the inkstand inside!
Horror and confusion reigned; the chaplain fainted away; the
servants were petrified—and then, losing their heads, dashed up with
sponges, brooms, and pails of water, and fell upon the map with zeal
so fatal that kingdoms, oceans, isles, and continents were
overwhelmed in common ruin.
George Sand declares she was not even touching the table at the
moment of the catastrophe—but adds prophetically that she quite
supposes the blame of it will to all time be laid at her door. The map
was subsequently restored by skilful hands to nearly its pristine glory,
and is now to be seen under glass in the house of the Count of
Montenegro at Palma.
The big monastery-church of Valldemósa contains little of interest
beyond some good marble mosaics, and hanging on the wall is a
curious apparatus not unlike a pool-marker, with lettered pegs that fit
into holes—the talking board used by the silent monks when they
wished to communicate with one another.
From Valldemósa an hour’s drive brings one to Miramár, the large
estate purchased in 1872 by the Archduke Louis Salvator. Before
arriving at the house itself one passes the roadside hospedéria, kept up
—with true Majorcan hospitality—by the lord of the manor for the
benefit of travellers: free quarters for three days, with firing, salt, and
olives, are offered to all comers, and the woman in charge cooks the
food that visitors bring with them. This hospice makes an excellent
centre from which to explore the north coast of the island, and good
walkers would discover countless delightful rambles amongst the
pinewoods that clothe the cliffs down to the water’s edge.
The Archduke’s own house is a plain building standing 2,000 feet
above sea-level; the name Miramár—Sea View—has attached to the
site ever since the thirteenth century, when Don Jaime II.—acting on
the recommendation of Rámon Lull, his seneschal—founded a college
there. Never was a name better deserved; like a silver mirror the placid
Mediterranean lies outspread below one, its motionless surface flecked
with tiny fishing boats; dark, fir-clad cliffs slope precipitously to the
sea, and far below lies the red rock Foradada like some gigantic saurian
in the blue water. Look-out points, or Miradórs, are constructed in
various parts of the grounds, commanding glorious views; and perched
upon a rocky spur lower down the hill is a tiny chapel, recently built,
dedicated to St. Rámon Lull. One of its foundation stones was brought
from Bougie in Algeria—where the saint met his death by stoning—and
another from San Francisco, in memory of the missionary Juan Serra,
the Majorcan founder of the Pacific city.
For the last eight years the Archduke has not resided at his Majorcan
home, greatly to the regret of the people; the house is uninhabited,
but is shown to visitors by the caretaker.
Its chief interest consists in the entirely native character of its
contents; everything in the house is Majorcan—the thick, soft matting
on the floors, the string-seated rocking-chairs and the fat stools of
stuffed basket-work; the handsome brass braziers and the carved four-
post bedsteads; the inlaid chests and cabinets, and the splendid
collection of faïence ware, of which the owner is a connoisseur.
Majorcan too is the vulture in the garden—a fierce, brown bird, who
hisses at visitors, and jumps wrathfully from branch to branch of the
aviary in which he has lived for seventeen long years.
“The port of Soller is a fishing village of
narrow streets....”
(page 89)
“We came up with a palmer from the
Holy Land, posting along at five miles an
hour.”
(page 87)
The Archduke is the author of a very exhaustive and profusely
illustrated work on the Balearics, “Die Balearen in Wort und Bild”; but
unfortunately it is too costly a work to become generally known, or it
would bring many travellers to visit the islands which the author loves
so well.
On leaving Miramár we continue along the coast to Deya, a
picturesque village of clustered houses and steep streets of steps,
perched upon an isolated peak and backed by high mountains. Here we
caught sight of a strange figure striding along the road ahead of us,
and presently we came up with a holy palmer, who might have stepped
straight out of the twelfth century—with cockleshells and staff, and
with his sandal shoon. He was posting along at five miles an hour with
a dog at his heels.
“Whither away, O Father?” we asked with respectful salutation.
“Over the whole world, my children,” replied the old man, turning
upon us a rugged face framed in long grey locks.
We learnt that he was a native of Spain, and had for years been on a
pilgrimage to the most sacred shrines in all lands; he had been in the
Holy Land and in Egypt—had visited St. James of Compostella, and
Rome, and Lourdes—and now was on his way to the shrine of Our
Lady of Lluch. His wallet contained his papers—viséd at his various
halting places—together with a few treasured relics from the Holy
Sepulchre; of money he had no need, since the faithful everywhere
would give him food and a night’s lodging, for the labourer is worthy of
his hire. But he dare not tarry, for he had yet far to go, and with a
“Buen viaje!” we drove on and soon lost sight of the solitary pilgrim
who in this strange fashion was working out his own salvation.
The town of Sollér lies almost at sea-level, in a spacious valley ringed
round with mountains around whose grey peaks buzzards and ravens—
dwarfed by distance to the size of midges—circle and slant for ever to
and fro.
Warm and sheltered, rich with orange and lemon groves, date palms
and loquats, and entirely enclosed with hills but for an opening down
to the little port on the north, Sollér is Majorca’s garden of the
Hesperides. Though it is only April 3rd, the roses are running riot in the
gardens of Son Angelāts, a fine house on the outskirts of the town
belonging to a Marchésa who only resides there in summer time; it has
terraces overlooking Sollér, and large grounds laid out with orange
groves, tall palms, and flowering shrubs; roses cover the terrace walls
and climb up into the grey olive-trees from whence they fall back in
festoons—and the gardener breaks off branch after branch for us as we
go along, great yellow Marshal Niels, pink La France, crimson tea roses,
butter-coloured Banksias, miniature roses de Meaux, and fragrant
Madame Falcot; we have more roses than we can carry. The borders
are full of pansies and polyanthus, Parma violets and carnations; we
are given bouquets of spirea, freesias, peonies, and heliotrope, and we
drive away with our little carreta decked out as if for the Carnival.
The Marchésa has beautiful grounds—carriages and horses, and
many servants; and to these possessions she adds, with true Southern
incongruity, a most remarkable approach to her entrance gate; several
yards of decayed cobble paving—bestrewn with loose blocks of stone
and full of deep holes—over which a small stream swirls rapidly,
intervene between her carriage gate and the road outside. The bumps
and crashes with which our cart forded the water nearly threw the
pony down, and we feared at one time that a wheel was coming off,
but we got through intact. That the marchioness should enjoy this
episode as part of her daily drive strikes even the natives, I think, as a
little strange.
The modest little hotel La Marina at Sollér is a great improvement on
the ordinary village fonda; the cooking is good, the bedrooms plainly
but suitably furnished, and the proprietor and his daughters spare no
pains to make their guests happy. Mules can be procured in the town
for mountain expeditions, a carriage and pair is kept for hire, and there
is a toy carreton belonging to the hotel in which one may drive out
alone—feeling somewhat like a coster going to the Derby; the minute
white pony hurries one along at extraordinary speed and stops for
nothing but the Majorcan word of command—Poke-a-parg!
The port of Sollér, about half an hour distant, is a little land-locked
harbour with a fishing village of narrow streets and picturesque houses.
Majorca’s northern coast is in general so precipitous and inhospitable
that the safe anchorage offered by the Sollér harbour was a great
attraction to the corsairs of the Middle Ages, and many and terrible
were the struggles that took place in the sixteenth century between
them and the inhabitants of Sollér; on one of these occasions they
sacked and then burnt to the ground the great Oratory of Santa
Catalina, which stands on a headland at the mouth of the harbour.
After this a castle was built, whose guns commanded the entrance to
the port; but of this nothing remains except part of a tower, now
incorporated in a modern dwelling-house.
There are many expeditions to be made on foot and on muleback
into the mountains that surround Sollér; stalwarts can make the ascent
of the snow-crowned Puig Mayor—Majorca’s highest peak, five
thousand feet above sea-level—or visit the Gorch Blau, a ten hours’
expedition, with several miles of rock steps to come down on the way
back, but both of these require strength and endurance. Then there is
the Barránco, a ravine, clean cut as with a knife, upon the summit of a
grey mountain ridge from whence a splendid view is obtained; and
there is the Torrent de Pareys on the north coast, to be reached by
boat on a calm day in about two hours.
“The white town of Soller lying in the lap of the hills, framed
by converging mountain slopes ...”
(page 92)
“Many of the houses at Fornalutx are
extremely old, with quaint staircases and
old stone archways.”
(page 91)
Of the shorter excursions one well worth making is to the hill village
of Fornalutx; the road runs up the valley of the Torriente, a bubbling
hill stream with banks of blue and white periwinkle and a masonry bed
overhung with thousands of orange and lemon trees, beneath which lie
oranges in golden mounds, like cider apples in a Somerset orchard. In
spite of the scale disease, which in latter years has wrought havoc in
many groves—blackening the fruit and destroying the foliage—the
oranges of Sollér are still famous, and fetch market prices ranging from
a penny to fivepence a dozen, according to quality, while a dozen of
the best lemons are here sold for twopence.
The streets of Fornalutx are principally flights of broad cobbled steps,
and many of the houses are extremely ancient and fascinating, with
quaint wooden balustrades, carved window frames, and old stone
archways. One of those we visited had an oil mill on the premises, and
we were shown the stone bins into which the panniers of olives are
first emptied, and the great trough in which they are subsequently
crushed with a millstone turned by a mule; the olive pulp is then placed
in flat, circular baskets, and when these are piled up in layers to a
considerable height, boiling water is poured over them and they are
crushed flat by an immense baulk of timber that descends upon them
from above. The exuding liquid flows into a tank below, where by the
happy provision of Nature the oil is able to be drawn off by a surface
pipe while the water is carried away by one at the bottom. The olive
harvest takes place in October and November; the oil is much used in
Majorcan cookery—though not to any unpleasant extent—and children
are often seen eating slices of bread spread with oil in place of the jam
or dripping with which it would be flavoured in our own country.

Our stay at Sollér was cut short by the unkindness of the weather.
For two days the rain held off, grudgingly; but on the third we awoke
to find the whole valley enveloped in a dense Scotch mist; our host
looked up at the blurred outlines of the mountains, and he looked at
the gusts of cloud that were blowing through the barranco, and he
shook his head; he was honest, and he confessed that the prospect
was not hopeful. A rain wind sobbed round the house as we sat over
the wood fire that evening, and from an adjoining room came the
singularly monotonous chant—high, nasal, and quavering—with which
a Majorcan servant girl can accompany her sweeping for hours at a
time. The effect was indescribably triste, and our thoughts turned to
the flesh pots of Palma.
The following morning showed no improvement, so our host’s
victoria was requisitioned and we set out on our return to the Grand
Hotel. For an hour and a half our two sturdy horses toiled up out of the
valley, the winding zigzags of the road affording us now and again a
backward glance at the little white town lying in the lap of the hills,
framed by converging mountain slopes. On reaching the top of the
pass we met a fresher air, and we rattled merrily down the beautifully
graded road towards the plain, drawing up presently at the wayside
villa of Alfádia.
Alfádia is an ancient caravanserai that still bears traces of its Moorish
origin; passing under the high entrance gateway, which has a Moorish
ceiling of carved and painted wood, one enters a vast courtyard,
surrounded by stables and containing a fountain and a pepper-tree of
immense size and age. When first we entered the great quadrangle it
was absolutely deserted, but no sooner did our camera mount its tripod
than with the mysterious suddenness of Roderick Dhu’s men figures
emerged from all sides, anxious to be included in the picture.
Hardly had we regained our carriage when the rain that had long
been threatening began to come down—first gently, then harder, and
finally with a terrific clap of thunder we were overtaken by a kind of
cloudburst. Whipping up the horses our driver made a dash for a
wayside inn on the Palma road, and driving in under the deep
verandah-like porch running along the whole front of the building we
drew up and were gradually joined by other refugees till every inch of
standing room was taken up. Cheek by jowl with us were white-tilted
orange carts from Sollér, a countryman and his cow, a post cart, sundry
mules, and a number of pedestrians who arrived half drowned beneath
their umbrellas; and in this most welcome shelter we all remained
imprisoned while for the next half hour it rained as I have never seen it
rain before. Cascades fell from the edge of the verandah roof, the road
became a river, and from the olive grounds gory floods were
descending and were struggling and leaping through the culverts like
the legions of red rats charmed out of Hamelin by the pied piper.
It is with diffidence that I venture to observe that a very unusual
amount of rain fell around Palma this spring—for there is a growing
feeling of incredulity on the subject of unusual seasons. I have heard of
a man who had lived for thirty years in Algiers, and who asserted that
in that time he had experienced thirty unusual seasons. Few winter
resorts perhaps could equal this record, but I fancy that in most places
abnormal seasons of one kind or another are sufficiently common for
the really normal one—when it does make its appearance—to be
almost, if not quite, as unusual as the rest.

On April 16th we took the train for Alcúdia and set out on our fourth
and final tour in Majorca. When I say that we took the train for Alcúdia
I mean that we went as far in that direction as the train would carry
us, for with a strange perversity the railway line, instead of running
right across the island from Palma to Alcúdia and so connecting the
latter and its Minorcan service of boats with the rest of the world, stops
short some ten miles from the coast, perhaps with a view to annoying
possible invaders.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like