CSCE3600 - Exam 2 Flashcards
an independent stream of instructions that can be scheduled to be run by the OS
thread
a program with multiple streams
multithreading
threads share…
memory and files with other threads that are in the same process
ownership of memory, files, and other resources
process
makes shell
system()
initiate new programs and replaces this process with a new one
exec()
creates new process, start a concurrent process, creates a child process by making copy of parent
fork()
two reasons for fork to fail
too many processes in the system
total number of processes exceeds system’s limit
semaphores can be initialized to….
any value
semaphores are used for
pthread blocking
if semaphore value is less than or equal to zero…
threads are blocked
if semaphore value is greater than zero
blocked threads wake up
when multiple processes use shard data and final outcome depends on order in which processes run
race conditions
creates a thread
pthread_create
set thread to release
pthread_detach
test two thread IDs for equality
pthread_equal
exit a thread without exiting process
pthread_exit
send a signal to a thread
pthread_kill
wait for a thread
pthread_join
find out own thread ID
pthread_self
allow threads to synchronize based upon the actual value of data
condition variables
explicit queue that threads can put themselves in when state of execution is not desired
waiting on a condition
another thread can wake up one/more waiting threads to allow them to continue
signaling on a condition
a per-process, unique, nonnegative integer used to identify an open file for the purpose of file access
file descriptors
each file descriptor refers to exactly _____ open file descriptors but an open file description may be referred to by _____ than _____ file descriptor
one, more, one
specification whether the file can be read and written
file access modes
the byte position in the file where the next I/O operation through that open file description begins
file offset
append mode or not blocking/non-blocking
file status includes
creates a copy of the file descriptor oldfd
dup()
makes newfd be the copy of oldfd closing newfd first if necessary
dup2()
used only with related processes:
parent/child
child/child
unnamed pipes
exists only as long as the processes using it are alive
unnamed pipes
redirects input from a file
redirects output to a new file
>
redirects output and appends the data to a current file or creates if file doesn’t exist
> >
both processes on same machine
UNIX domain
processes on different machine
INET domain
provides sequenced, reliable, two-way, connection-based byte streams (telnet, ssh, http)
SOCK_STREAM
supports datagrams (connectionless, unreliable messages of a fixed maximum length
SOCK_DGRAM
exec() returns _____ on error
-1
socket»_space; bind»_space; listen»_space; accept»_space; close
steps in server process
socket»_space; set up sockaddr_un»_space; connect»_space; send and recv»_space; close
steps in client process
little-endian reads _________ first
high-order (first 8 bits)
big-endian reads __________ first
low-order (last 8 bits)
well-known ports, reserved by IANA
ports 0-1023
registered ports
ports 1024-49151
dynamic ports, OS use randomly
ports 49,152-65,535
identifies a single host, variable length string (www.unt.edu)
hostname
written as dotted octets, 32 bits
IP address
identifies a process on a host, 16 bit number
port number
socket()»_space; sendto() (data request()»_space; recvfrom()»_space; close()
UDP Client flow
socket()»_space; bind()»_space; recvfrom()»_space; sendto()
UDP Server flow
socket(int _______, int _______, int ________)
creates the socket,
domain (AF_UNIX, AF_INET)
type (SOCK_STREAM, SOCK_DGRAM, SOCK_RAW)
protocol (set to 0)
bind(int ______, const struct _________ *_______, socklen_t _________)
bind the socket to an address in the UNIX domain
sockfd (returned by socket)
sockaddr *serveraddr
addrlen
listen(int _______, int _________)
instruct the socket to listen for incoming connections
sockfd
backlog
connect(int ______, const struct _________ *_______, socklen_t _________)
kernel will choose a dynamic port and source IP
sockfd (returned by socket)
sockaddr *serveraddr
addrlen
send(int ___, const void *____, size_t ____, int _____)
recv(int ___, const void *____, size_t ____, int _____)
s (socket descriptor)
buf (buffer of information to send to an empty buffer)
len (size of the buffer in bytes
flags (0 or MSG_EOR, MSG_OOB)
compiler optimization (4)
execution time, code size, memory usage, compile time
optimized for code size
optimization flag -Os
no optimisation, easy to debug but slower/larger
optimization flag -O0
optimize for both speed and size
optimization flag -O1 or -O
turn on most optimizations, enables instruction scheduling
optimization flag -O2
turn on some extra performance, might increase code size, but increased performance
optimization flag -O3
performs usually simple operations on the source files prior to compilation, sends output to stdout
preprocessor
translates from one language to another, saves example.s
compiler
assembles to relocatable object code, saves object
assembler
combines object code and assembling source program, as well as libraries to make executable
linker
gets an address to place program, changes necessary addresses, places code into memory
loader
modifies binary, inserting probes at function entry/exit to collect data
instrumentation
takes statistical samples of application performance
sampling