UNIX Programming Final REview

52 flashcardsby Jackson
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
make
Command line utility for compiling large programs
2
make command usage
make -f <makefileName> target
3
make triple
target: sources
\t command
4
make variable declaration
KEYWORD = contents
5
make variable usage
$(KEYWORD)
6
Phony make target
A make target that does not generate any files
7
make $@
Target name
8
make &^
All sources
9
make $<
Left-most source
10
Threads
A sequence of instructions executed independently of a parent process. Can be run in parallel.
11
What Threads Share
Process ID, Address Space (Code + Data + Memory), File Descriptors, Working Directory, User/Group ID
12
What Threads Don't Share
Thread ID, Registers, Stack
13
Thread compile flag
-pthread
14
Thread library
<pthread.h>
15
Thread creation
int pthread_create(pthread_t* thread, const pthread_attr-t* attr, void* (*startroutine)(void*), void* arg)
16
Thread exiting
int pthread_exit(void *value_ptr)
17
Wait for a thread to complete
int pthread_join(pthread_t thread, void **value_ptr)
18
Function signature for threading
void* func(void* args)
19
Thread 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.
20
Initializing a mutex
pthread_mutex_init(&mylock, NULL)
21
Acquiring a mutex
pthread_mutex_lock(&mylock)
22
Releasing a mutex
pthread_mutex_unlock(&mylock)
23
Networking Layers
Physical, Data Link, Network, Transport, Session, Presentation, Application
24
Physical Layer
Sendecieve bits over a medium (wire/air)
25
Data Link Layer
Multiple computers on a LAN. Specifies how bits are peketized. Uses Media access control (MAC) and network interface controllers (NICs).
26
Network Layer
Routes information between various networks by IP address. Defines a protocol to route packets.
27
Transport 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.
28
TCP
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.
29
UDP
Provides applications with unreliable packet delivery. A thin, simple layer on top of IP, with data still fragmented into multiple IP packets.
30
Two 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)
31
Application Layer
Defines a protocol for the format and meaning of messages between application entities, like HTTP or your favorite multiplayer video game.
32
Transmission Data Flow
Application -> Physical
33
Receiving Data Flow.
Physical -> Application
34
Socket
A file descriptor for network communications.
35
Types of Sockets
Stream, Datagram, Raw
36
Sream Sockets
For connection-oriented, point-to-point, reliable byte streams. Uses TCP, SCTP, or other stream transports.
Establish connection -> Communicate -> Close connection
37
Datagram Sockets
For connection-less, one to many, unreliable packets. Uses UDP or other packet transports
Create Sockets -> Communicate
38
Raw Sockets
For layer-3 communication (raw IP packet manipulation)
39
Client 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.
40
Server 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.
41
Shell
A program that lets a user or other program use an operating system's services or programs.
42
Bash
A shell program
43
Bash Variable
var=contents
echo $var echo "$var"
44
Bash Function
get_name() {
echo "John"
}

echo "You are $(get_name)"
45
Bash Execution
echo "I'm in $(pwd)"
46
Bash Conditional
if [[ -z "$string" ]]; then echo "String is empty" elif [[ -n "$string" ]]; then
echo "String is not empty"
fi
47
Bash Arithmetic
echo $((2+3))
48
RegEx
A sequence of characters that can match a pattern.
49
Regex 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
50
Cloud
A datacenter hardware and software that are used to offer computing resources and services
51
Cloud 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
52
Cloud 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
Study all 52 cards for free