1make
Command line utility for compiling large programs
2make command usage
make -f <makefileName> target
3make triple
target: sources
\t command
4make variable declaration
KEYWORD = contents
5make variable usage
$(KEYWORD)
6Phony make target
A make target that does not generate any files
10Threads
A sequence of instructions executed independently of a parent process. Can be run in parallel.
11What Threads Share
Process ID, Address Space (Code + Data + Memory), File Descriptors, Working Directory, User/Group ID
12What Threads Don't Share
Thread ID, Registers, Stack
13Thread compile flag
-pthread
14Thread library
<pthread.h>
15Thread creation
int pthread_create(pthread_t* thread, const pthread_attr-t* attr, void* (*startroutine)(void*), void* arg)
16Thread exiting
int pthread_exit(void *value_ptr)
17Wait for a thread to complete
int pthread_join(pthread_t thread, void **value_ptr)
18Function signature for threading
void* func(void* args)
19Thread Mutex
A lock for making sure there are no data races between threads. A thread can lock a mutex if it's unlocked, otherwise it has to wait until it's unlocked. Has type pthread_mutex_t.
20Initializing a mutex
pthread_mutex_init(&mylock, NULL)
21Acquiring a mutex
pthread_mutex_lock(&mylock)
22Releasing a mutex
pthread_mutex_unlock(&mylock)
23Networking Layers
Physical, Data Link, Network, Transport, Session, Presentation, Application
24Physical Layer
Sendecieve bits over a medium (wire/air)
25Data Link Layer
Multiple computers on a LAN. Specifies how bits are peketized. Uses Media access control (MAC) and network interface controllers (NICs).
26Network Layer
Routes information between various networks by IP address. Defines a protocol to route packets.
27Transport Layer
Provides an end-to-end direct connection, abstracting away connection details. Provides different protocols (like TCP and UDP) to interface between source and destination.
28TCP
Transmission control protocol. Provides applications with reliable, ordered byte streams. Sends stream data as multiple IP packets and retransmits them as necessary. When receiving, puts packets back in order and detects missing packets. A single host (IP address) can have up to 2^1 = 65535 ports.
29UDP
Provides applications with unreliable packet delivery. A thin, simple layer on top of IP, with data still fragmented into multiple IP packets.
30Two Hidden Layers
Session - Supposedly handles establishing and terminating application sessions
Presentation - Fragments data into multiple IP packets (???, the slides are unclear and it sounds like it's doing the work of the network protocol)
31Application Layer
Defines a protocol for the format and meaning of messages between application entities, like HTTP or your favorite multiplayer video game.
32Transmission Data Flow
Application -> Physical
33Receiving Data Flow.
Physical -> Application
34Socket
A file descriptor for network communications.
35Types of Sockets
Stream, Datagram, Raw
36Sream Sockets
For connection-oriented, point-to-point, reliable byte streams. Uses TCP, SCTP, or other stream transports.
Establish connection -> Communicate -> Close connection
37Datagram Sockets
For connection-less, one to many, unreliable packets. Uses UDP or other packet transports
Create Sockets -> Communicate
38Raw Sockets
For layer-3 communication (raw IP packet manipulation)
39Client TCP Connection
Step 1: Figure out the IP Address and Port. You may need to obtain the IP Address from the DNS via getaddrinfo(const char* hostname, const char* service, const struct addrinfo* hints, struct addrinfo** res).
Step 2: Create a socket using socket(int domain, int type, int protocol). This returns a socket file descriptor.
Step 3: Connect to a server using connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen).
Step 4: Use read and write to communicate over the file descriptor.
Step 5: Use close(sockfd) to close the connection.
40Server TCP Connection
Step 1: Figure out the IP address and port on which to listen. Again may need to use getaddrinfo(const char* hostname, const char* service, const struct addrinfo* hints, struct addrinfo** res).
Step 2: Create a socket using socket(int domain, int type, int protocol). This returns a socket file descriptor.
Step 3: Bind the socket using bind(int sockfd, constr struct sockaddr* addr, socklen_t addrlen).
Step 4: Create a listening socket that clients can connect to using listen(int sockfd, int backlog).
Step 5: Accept an incoming client connection using accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen).
Step 6: Use read and write to communicate over the file descriptor.
Step 7: Use close(sockfd) to close the connection.
41Shell
A program that lets a user or other program use an operating system's services or programs.
43Bash Variable
var=contents
echo $var
echo "$var"
44Bash Function
get_name() {
echo "John"
}
echo "You are $(get_name)"
45Bash Execution
echo "I'm in $(pwd)"
46Bash Conditional
if [[ -z "$string" ]]; then
echo "String is empty"
elif [[ -n "$string" ]]; then
echo "String is not empty"
fi
47Bash Arithmetic
echo $((2+3))
48RegEx
A sequence of characters that can match a pattern.
49Regex Rules
Sequence: ab
Range: [a-z]
Alternation apple|cherry
Repetition: a{2,3}, a*, a+, a?
Group: (ab)
Beginning/End: ^, $
Match any character: .
Match any word character: \w
50Cloud
A datacenter hardware and software that are used to offer computing resources and services
51Cloud Types
Public Cloud - Available to the public, pay-as-you-go, service sold is utility computing
Private Cloud - Internal data-centers of organizations not available tothe public, managed internally or by third-party providers, involved CapEx
Hybrid Cloud
52Cloud Service Models
Infrastructure-as-a-service - Basic computing resources, users control the software stack from the kernel upward, provider cannot offer scalability and fail over
Server-less - Application domain specific platform (AppEngine), request-reply based, automatic scaling, not suitable for general purpose computing
Platform-as-a-service - Supports general purpose computing, users can choose language but not libraries, OS, automatic scaling but requires configuration by users