Life in the clouds, Googie style (1962).
Pirate Programming
by: burt rosenberg
at: university of miami
date: september 2023
Overview
The Jetsons were not pirates. They were a typical middle-class family living in
the future. They were a creation of the
Hanna-Barbara animation studio. The style of the Jetsons was something called
Googie, and there
are several Googie style buildings
in existence.
We however, will attempt some pirate programming, and we will hence need a cyber-ocean
and cyber-ships. That is the story line behind doing this project in the clouds, on
a virtual machine instance using AWS, an Amazon product. Other vendors provide similar
services — an instance of computing in the cloud, called cloud computing.
If you really want to know what is cloud computing, probably best to read
Above the Clouds,
a Berkeley tech report with a bunch of names on it.
This page has the following sections,
You will need an EC2 instance
Because this work is pirate programming, it matters a lot what machine and what operating
system is being used. In order to get us all on the same machine, we will use an
EC2 instance.
architecture: x86_64
OS: Canonical, Ubuntu, 22.04 LTS, amd64
An EC2 instance is a virtual machine instance running in one of Amazon's server
farms, typically a virtual machine, so that its spin-up and spin-down is entirely
software. It is part of Amazons Amazon Web Services (AWS) offering.
You upgrade your Amazon account to include AWS. The upgrade is free, but they
need to inform you about possible charges to your credit card, and get your permission
for these charges.
Note: Amazon has a Free Tier for the first year of AWS usage. Otherwise,
use Free Tier eligible resources for the lowest charges.
☞
And please remember to terminate your instances!
Creating an EC2 Instance
-
You will create a computing instance from a compute instance,
(EC2).
-
A storage instance
will be created for you, and attached to the compute instance,
(EBS)
-
You will be asked to create a public-private key pair, and download the private key.
Keypair
-
You can chose to stop or terminate your instance when done.
-
Terminating releases the EBS storage instance, and you now will have not further
charges to your credit card.
-
Stopping maintains the EBS storage, and you pay monthly on that storage. However,
you can restart the instance and pick up where you left off.
- Return to the dashboard for instances, select your instance.
- Click connect for a panel giving your instructions for an ssh connection.
- Get the repo information: sudo apt-get update
- Make sure your software is up to date: sudo apt-get upgrade
- Install all the needed software: sudo apt-get install build-essential git
- Stop your instance until you wish to continue or to terminate the instance.
Pirate Programming
We have idealized memory as an array of bytes indexed from 0 by consecutive integers.
For each basic type, and for void, we have a pointer type that we conceptualize
as the integer address at which an element of that type resides in memory.
- If the type is of multiple bytes, the value occupies successive bytes in memory, and
the lowest index is the address of the value. Usually this address is adjusted so that
it is divisible by the number of bytes required for the value.
- If the type is a function, the value is conceptualized as the starting address of the
code in the memory.
Whether this is true or not is obscured by the exact C Language specifications. (For instance,
what can be found in Harbison and Steele). Reading
that manual carefully, pointer value are returned either by malloc, or the address-of operator.
A pointer can be added to, which moves the pointer to the next item in a sequence of items.
However, they are silent on coercion or conversion between
pointers and integers.
Coercion is a compiler concept. No code is emitted to coerce
a value from one type to another. Conversion is an execution concept.
Code is emitted by the compiler to execute at run time to accomplish
the conversion — e.g. from integer to float.
To ignore this and go ahead with programming outside the specification, I call
pirate programming.
We are going to engage in pirate programming to explore our understanding even if
our code might not be portable. This is a nightmere for code
that is supposed to go into a reliable software product, but we are pirates.
The diagram on the right shows exactly how memory address are handled in the 32 Intel
architecture. There is a Linear Address Space that is an array of bytes indexed
by consecutive integers. However, the space is cute into segments that differentiate
different memory arenas. In a Von Neumann architecture,
the code arena finds a place within the Linear Address Space. The competing
Harvard architecture places
code in a separate arena, and is very useful for embedded devices where code is in ROM
(Read Only Memory) and data is in read/writable memory — different devices accessed
in electrically distinct pathways. This is one example of how the linear address space
concept is important.
The 64 bit architecture is different. This is called either x86_64 or amd64.
For Intel this defines a 48 bit virtual address
embedded in an 64 bit linear span. The 248 virtual address are not all
in the lower arena nor all in the upper arena of the 264 linear addresses,
but are split, with a middle gap where the linear addresses are invalid.
Also note that Intel defines the physical address space in a flexible manner, according
to the particular chip, up to 56 bits of address space.
The Pirate Programming Project
You have received a github classroom invitation to the code template. There are two programs to
complete. Much of the code is good, but you need to find the pirate secret and the pirate treasure box.
In one program the treasure is the return_to address, and but hijacking that you can
"board the ship", that is, return from a call to the function of your choice. In the other the
treasure is at the location. At that location is the pointer to a string to print. The
pirate who over-writes this location hoists his pirate flag! that is, prints their string not
the one given in the function call.
The ref files give example output for a successful run. However, what matters is that
your program works, not that it match the output.