prepare for interview Flashcards

1
Q

Hard Disk

A

Non-volatile data-storage device. rotating magnetic disk.

Uses magnetic storage to store and retrieve digital information. composed of one or more rapidly rotating platters coated in thin magnetic material. Data accessed in random-access manner (can be stored and retrieved in any order).

Non-volatile: retain stored data when powered off.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Computing Machine

A

Machine that does something based on input, and produces output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Turing Machine

A

‘the blueprint of modern computing’. ‘Machine’ that recieves a tape of 1’s and 0’s, reads it, changes 1’s to 0’s and 0’s to 1’s according to instructions. the tape that used to be a question becomes an answer to the question.

Initially just a theoretical idea of a device that, when given a tape of whatever needed length of 1s and 0s, reads the tape and changes the 1s and 0s in accordance with its instructions. the tape of 1s and 0s starts as a question, and when the turing machine is finished with it, becomes the answer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Von-Neumann Architechture

A

computer model designed by John Von-Neumann in 1945.

Input -> Memory -> Output
V> Processor (Control Unit <->Arithmetic Logic Unit)

+ Input stored as command in Memory,
+ Processor fetches command from Memory,
+ CU manages commands and input/output,
+ ALU handles calculations,
+ CU stores complete commands in memory,
+ Output is displayed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Operating System

A

Program that allows a user to interact with the computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

History of Linux

A

developed by Linus Torvalds.

started in 1991 as a pet project,

became community open source project

Linux 1.0.0 launched in 1994

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Linux?

A

Open source Operating System. Android is based in Linux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

CPU

A

Central Processing Unit. interprets and executes all instructions. consists of single microprocessor, but stronger mainframes use one or more. contains CU and ALU (Command Unit, Arithmetic Logic Unit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. CPU cache
A

Stores temporary files.

Small chunk of memory on the computer’s processor that stores basic computer instructions that were recently or are frequently used.

Makes processing go faster because frequent data close to CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

RAM

A

Computer memory that can be read and changed in any order.

Typically used to store working data and machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ROM?

EPROM?

A

Read-Only Memory. Non-volatile memory, cannot be electronically modified after manufactury.

Erasable Programmable, read only memory. can be erased if exposed to certain ultraviolets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

BIOS

A

Basic Input Output System

Boot Loader
Computer instructions in ROM in motherboard chip.
Controls input and output operations.
Loaded into memory on startup, performs POST (power on self test), then loads OS from hard drive into memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

BUS (Address, Data, Control)

A

Set of wires carrying signals between devices. connect CPU, memory and I/O devices.

Address bus: carries the address of memory location/ IO device CPU is communicating with

Data bus: carries data between CPU and memory / IO device

Control Bus: carries control signals, telling IO devices what to do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

I/O device

A

Any external device that could send input or receive output.
(secondary storage, keyboard, mouse, monitors, printers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

File system

A

The way in which files are named and placed logically for storage and retrieval.

NTFS, NFS and ext4 are file systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Program

A

Set of code and instructions meant to complete a task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Process

A

Running instance of a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

USB

A

Universal Serial Bus

Technology that connects computers with external devices

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Serial Port

A

Connector that sends data one bit at a time.

May be connected to a computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Parallel port

A

Device Connector,

sends/receives several bits of data simultaneously using more than one wire.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

RS-232

A

slow but reliable standard transferring data as voltage signal. relatively slow, used still for modems, printers, and other peripherals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

(U)EFI

A

Unified Extensible Firmware Interface.

Boot Loader, Replacement for BIOS, controls startup process. supports larger hard drives, faster boot times, improved security, adds GUI to configure UEFI settings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Boot Loader

A

Loads an operating system when a computer is turned on. Stored in non-volatile memory (ROM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

GRUB/LILO

A

GRUB: new boot loader with multi-OS device management. Supports Windows, Linux, UNIX, macOS, BSD, and Solaris.

LILO: older boot loader with single OS device management. Only supports Linux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

ATAPI

A

Advanced Technology Attachment Packet Interface

Extension for ATA(/IDE) standard, allows non-hard drive devices to connect to computer (CD-OMs, DVDs, Blu-ray).

Uses command-based protocol allowing host computer to send commands to the device and receive data from it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

SATA

A

Serial Advanced Technology Attatchment

Replaces older PATA (Parallel) standard, used for hard drives, SSD’s and optical drives.

(remember ATAPI)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Master Boot Record

A

Boot sector at beginning of storage device (holds partition table + bootstrap code)

Locates OS, loads it to memory, transfers control to OS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

MTBF

A

Mean Time Between Failiures.

Average time between breakdowns, used to measure performance/safety

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Swap File

A

System file that creates temp storage on SSD/HD when system low on memory.

Swaps section from RAM storage from idle program to be used by other programs.

Simulates disk space as RAM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Virtual Memory

A

OS technique using hardware and software to temporarily transfer data from RAM to disk storage.

Compensates for physical memory shortage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Inode

A

File data structure, stores metadata about a Linux file (except name and data)

Keeps track of all files in Linux System.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

ASCII table

A

America Standard Code for Information Interchange: assigns numeric IDs to each letter, numeral, punctuation and other characters.

Subset of Unicode, developed in 1960’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Unicode

A

Worldwide encoding standard.

developed in 1980’s to support a total of 65,536 characters (including ASCII) and more from other languages and scripts.

Unicode characters take variable length characters, and therefore take more space than ASCII.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

wchar

A

Wide Character.
Size of wchar is implementation-defined, but typically 16 bits.

wchar_t *wide_string = L”Hello, world!”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

UTF-7/8

A

7-bit / 8-bit encoded Unicode Transformation Format.

7 is backwards compatible, still used in emails. 8 is more efficient and supports more characters, used for web and other applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

POSIX

A

Portable Operating System Interface

set of OS interface standards based on Unix. Any two software conforming to POSIX standard should be compatible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

GNU

A

GNU’s Not Unix
Unix-like OS; Collection of programs (applications, libraries, developer tools, and games)
Started by Richard Stallman in 1983, as the GNU Project.
goal: create a free OS that is compatible with Unix.

relevent components:
GNU Compiler Collecction (GCC),
GNU Debuger (GDB)
GNU C Library (glibc),
Bourne Again SHell (bash)
And of course others

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

IP / TCP / UDP

A

Internet Protocol, responsible for routing data backets between computers

Transmission Control Protocol: does the TCP handshake and ensures all packets reach their destination

User Datagram Protocol: connection-less protocol, which does not guarantee data is delivered reliably or in the right order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Kernel

A

Core of the OS. All system calls from User Space communicate with the Kernel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

System Call

A

routine that allows user apps to request actions that require special privelages (create, delete, open, close, read, write)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Waterfall

A

Project Framework that breaks down of project activities into linear sequential phases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

SCRUM

A

Project Framework that starts with what can be seen/known. then tracks progress and tweak as necessary.

Emphasizes teamwork, accountability and iterative progress.

Is an example of Agile Development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Agile Development

A

Project Framework for iterative and incremental development.

+ rapid, flexible responses to change.
+ customer collaboration over contract negotiation
+ responding to change over following a plan
+ working software over comprehensive documentation

Scrum and Extreme Programming are forms of Agile Development

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

NTFS

A

New Technology File System

Used by Windows NT for storing/organizing/finding files on a hard disk. Direct upgrade to FAT16/32.

Reliable: Is a Journaling file system (keeps track of file changes in journal for recovery)
Efficient: features file compression and sparse files
Secure: supports Access Control Lists (ACLs) to control file access.
Encryption: supports file encryption to be accessed by authorized users.

Default file system for windows NT, 2000, all the way up to windows 10.

Also supported by Linux and macOS, but those primarily work with ext4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

NFS

A

Network File System

Protocol for storing files on a network. Distributed file system for accessing files/directories on remote computers and treat them as if they were local.

Scaleable (can add more users/devices)
Reliable (withstands network failiures)
Efficient (uses network resources as opposed to shoving more physical memory into a machine)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

FAT-16/32

A

File Allocation Table

FAT16, introduced in 1977, for Floppy disks. stores file/folder info as 16-bit entries. max size of FAT-16 partition is 2GB

FAT32, introduced in 1996, for USB flash drives and SD cards. stores file/folder info as 32-bit entries. max size of a FAT-32 partition is 32TB.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

JFS

A

Journal File System, created by IBM.

Meaning the file system tracks changes to files and folders in a log file, to backtrack changes in case of system crash or power failure. ext4 is a JFS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

ext4

A

Fourth Extended File System (after ext1, ext2 and ext3)

Journal file system (JFS) for Linux. higher supported size (1 exabyte).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

Primary Disk Partition

A

first part of MBR partitioned hard drive.

stores OS, boot files (that start the computer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Extended Partition

A

Partition that holds multiple logical partitions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Logical Partition

A

Partitions that hold data and applications. (Data files, Media files, Applications, Backups, Games, Software)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

What are the 9 sections of the manual? (man command)

A

1 General Commands
2 System Calls (provided by kernel)
3 Library Functions (from program libraries)
4 Special Files (usually to do with /dev/)
5 file formats and conventions (usually to do with /etc/)
6 games: oops
7: Miscellaneous: Macro Packages and Conventions, boot parameters,
8: Sys-admin commands: usually reserved for root
9: Kernel Routines: info about internal kernal operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

which command tells you which manual section the “write” command is in?

A

man -f write // returns page/section write is in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

When there is more than one program with the same name in the file system, how do you know which will run?

A

1: program in the same directory will run first,
2: else, the OS will look for the first program that appears in the $PATH environment variable,
3: if it doesn’t exist, OS returns an error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

what do the “which” and “type” commands do?

A

which returns the path to the executable, and type returns information, like if the command is internal/external

which ls
returns: /bin/ls

type ls
returns: ls is a shell builtin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

write an alias to remove files ending with ~ from the current directory

A

alias rt~=’rm -r *~’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

In which file would you place an alias so that you have it when you start a new bash?

A

~/.bashrc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Create a shell function that checks if a file exists. if it does, then copy it to /tmp

A

!/bin/sh

FILE=1

echo “please enter file name.”
read FILE

if test -f “$FILE”; then
cp “$FILE” tmp/”$FILE”
fi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

login to another computer and run gedit on a file in /tmp. ensure that the window that opens is on your computer, and not the remote computer

A

ssh username@host_ip_addres
cd /tmp
touch whatever.txt
gedit whatever.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

What is the command for knowing who is logged in?

A

who -b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

What is the command for checking last reboot?

A

last reboot

62
Q

What is the command to confirm your IP address?

A

ifconfig

63
Q

What are the commands you can use to see computer resource usage?

A

top

htop (for better view)

nmon

gnome-system-monitor

64
Q

What is the command for setting your computer’s clock?

A

sudo timedatectl set-time hh:mm:ss

65
Q

Write a shell script that records the current time to a file in /tmp

A

!/bin/sh

touch “/tmp/date.txt”;
echo $(date)&raquo_space; “/tmp/date.txt”;

66
Q

Command to know how long it takes for -ls -m to run?

A

time -ls -m

67
Q

What are the differences between crontab, at and batch?

A

Cron: runs tasks at regular intervals (once a minute, once a day…) think backups and notifications

crontab -e
0 2 * * * echo howdy //echoes at 2am every day

At: runs task at a later time (think running a test suite or compiling code)

at now +5 minutes
> notify-send “commit to bathroom”
> CTRL+d

Batch: just calls at, to run in the background.

68
Q

command to know what processes are running on the machine?

A

ps aux

69
Q

command to know PID of shell environment?

A

echo $$

70
Q

ls command, but display hidden files?

A

ls -a

71
Q

ln VS ln-s

A

Hard Link: Creates a file sharing the same inode. Good as backup, files are deleted when their last hard-linked pointer is deleted.

Soft Link: creates a file pointing to the other file’s location. soft link can point to files in other file systems.

72
Q

think about pushd popd

A

take your time.

73
Q

Why are the -i, -r and -f flags for cp, mv and rm?

why doesn’t mv have -r?

A

-i interactive (prompts “are you sure you want to delete/overwrite?”)
-f force (if it cannot be opened, delete and try again)
-r recursive (take into account all subfiles/subdirectories)

mv works with recursive flag by default.

74
Q

command to check used disk space?

A

df,

or df -h for human

75
Q

command to edit file permissions
remove write and execute from group and others.
give read write execute to user.

set owner of the file to “guests” group

A

chmod go-wx file.txt
chmod u+rwe file.txt

sudo chgrp g-rwx file.txt

76
Q

command to add a guest account with guest password to machine

create a guests group,

add guest to guests group

A

useradd guest
passwd guest 12345

groupadd guests
usermod -a-G guests guest

77
Q

count the number of words that start with ‘a’ and end with ‘z’ in the dictionary file, and print the number to a file in /tmp

A

grep -c “^a.*z$” /usr/share/dict/words

78
Q

Display the words in a file containing qui respelled with kwi

A

grep -E “qui|kwi” file.txt

79
Q

in a command: what are the last 20 words in the dictionary?

A

tail -20 /usr/share/dict/words

80
Q

What is the difference between a swap file and a swap partition?

A

swap file handling is more flexible, but slower. (can’t enlarge a swap partition without disk management tools)

Swap partitions are faster, and more common.

81
Q

What is Bash?

A

Bourne Again Shell.

command language interpreter, executes commands read from .sh file.

82
Q

Global Variable in Bash

A

variable declared outside of any function or loop, and can be accessible from anywhere in the script.

83
Q

printenv (bash)

A

prints environment variables

84
Q

What is the meaning of #!/bin/bash

A

“shabang”.

inscructs the program loader to use the /bin/sh program instead of any other, passing the path of the script as the first argument.

85
Q

How do you make multiline comments in bash?

A

: ‘

will not execute

86
Q

What is Version Control?

A

AKA source control, the practice of tracking and managing changes to software-code.

version control tools help software teams manage changes to source code over time.

Git is a Version Control Tool

87
Q

Define Git

A

Distributed Version control system

88
Q

What is a Git repository?

A

collection of files and folders that are tracked by Git

89
Q

What is the Git HEAD?

A

Pointer to the current commit.

git checkout makes the HEAD point to a different branch.

git commit sets the head file to point to the current commit.

90
Q

What is the Git Staging Area?

A

files to be handled by the next commit.

git add adds files to the staging area

91
Q

What is the difference between git fetch and git pull?

A

fetch downloads changes to local repository,

git pull calls fetch AND merges them into your local branch.

92
Q

What is the difference between the HEAD and the master?

A

HEAD is a file located in the .git directory. contains pointer to current commit.

Master is a branch in the git repository. a branch is a pointer to a specific commit.

93
Q

What is the difference between git reset –hard and git reset –soft?

A

soft reset: moves HEAD to the specified commit, and un-stages files added to staging area between current state and specified commit.

hard reset: destroys all changes and removes them from the working directory, staging area and commit history.

(soft reset un-adds changes. hard reset deletes changes.)

94
Q

What is a sequence point?

A

a point in the code where previous expressions have to resolve before proceeding.

examples: && || , ;

function calls, return, the conditional expressions of if/while/do…

95
Q

C escape character for newline

A

\n

96
Q

what defines an expression as having an l-value, and what is a side effect?

A

expressions with l-value have a persistent (FINDABLE) location/address in memory.
(a = 7; /you can find the address of &a/)
(10 += 7; /* you can’t find the address &10 */)

97
Q

What is the difference between a declaration and a definition?

A

Declaration tells the compiler about the existence of a variable/function/object.
int x; void function();

definition tells the compiler the location and size of a variable/function/object.
int x = 10; void function() { return 10; }

98
Q

What is the difference between unspecified and undefined behavior?

A

Unspecified: undefined by programming language standard

Undefined: undefined by programming language standard AND will cause unpredictable program behaviour

99
Q

What is the difference between unspecified and undefined behavior?

A

Unspecified: undefined by programming language standard
- function arguments can be evaluated in different orders,
- pointers pointing to uninitialized memory

Undefined: undefined by programming language standard AND will cause unpredictable program behavior
- accessing array element out of bounds
- dividing by zero
- de-referencing null pointer

100
Q

what defines Data, Stack and Heap variables?

A

Data variable: allocated in data segment, initialized when program starts, de-allocated when program ends. int x = 10;

Stack Variable: allocated in stack segment, initialized when function is called, de-allocated when function returns (most anything inside functions)

Heap Variable: allocated in heap segment (for dynamically allocated memory), initialized when allocated, de-allocated when freed. (malloc, calloc, free)

101
Q

What is an array?

A

collection of variables of the same type

double balance[3] = {1.2, 3.4, 5.6}

102
Q

What is Forward Declaration?

A

declaring a variable before providing a definition.

int func();
//code
int funct(){ return 7;}

103
Q

what does assert do in C?

A

include <assert.h></assert.h>

void assert(int expression);

prints message to stderr and aborts the program if false or 0.

“Assertion failed: expression, file filename, line line-number.”

104
Q

What will happen if you use a dangling pointer?

A

segmentation fault (please use free)

105
Q

in debugging, what is breakpoint, watchpoint and catchpoint?

A

breakpoint: stop executing at break line
watchpoint: stop executing when target memory location is modified
catchpoint: stop executing when a specific event occurs

106
Q

What is a memory leak?

A

program error, allocated memory isn’t freed.

107
Q

What is Word?

A

the size of the basic unit of data that a computer processor can manipulate.

depending on the computer architecture, this is either 32 or 64 bits, typically represented as an “int” by 32-bit or 64-bit computer.

108
Q

argc, argv and envp?

A

argc: variable, stores number of arguments passed to C program
argv: array, stores arguments passed to the C program
envp: pointer to array of pointers to environment variables

(environment variables being HOME, PATH, LANG, LC_ALL, USER, USERNAME, and more)

109
Q

given x = “toot”,
difference between sizeof(“x”) and strlen(“x”)?

A

sizeof will give the size in bytes (4 characters, 4 * 1 bytes)

strlen will return the length, including the escape character \0 (5)

110
Q

what are stdin, stdout and stderr?

A

Standard Input/Output/Error Streams; interconnected I/O channels between a computer program and its environment during runtime.

stdin recieves text as input.
stdout outputs text to the shell environment
stderr outputs error messages

111
Q

enum

A

Special type representing a group of constants

enum Level {
LOW,
MEDIUM,
HIGH
};

enum Level some_level;
some_level = LOW;
some_level = HIGH;

112
Q

struct

A

Groups related variables of varying types.

113
Q

chain of responsibility

A

Behavioral design pattern of passing requests down a chain of handlers. Each handler either processes the request or passes it to the next handler.

114
Q

what is a file, in linux?

A

A named collection of data on a storage device. can be text, images, programs, etc.

All files are organized under a file system.

115
Q

what is the difference between fopen() and open()?
what is the difference between what they return?

A

fopen() and open() are functions in C used to open files.

fopen() is a library function (implemented by C standard library). Returns a pointer to a FILE object. Has a variety of modes (“r” reading, “w” writing and “a” appending, and others).

open() is a system call (implemented by the OS). Returns an integer file descriptor (identifies the file on the OS)

116
Q

Header File

A

include header_file_name.h

.h file with declcarations and macro definissions to be shared between source (.c) files.

117
Q

Header Guard

A

ifndef FILENAME.H

#define FILENAME.H

code in header file to prevent duplicate implementation of the same code.

118
Q

Preprocessor

A

Macro processor, transforms .C into .i file, removes comments, runs macros

(header file inclusion, macro expansion, conditional compilation, line control [inform line’s origin file])

119
Q

Linker

A

links .O files together into single binary executeable.

resolves symbols,

assigns load addresses for object files.

120
Q

Compiler

A

transforms source code into machine (byte) code.

121
Q

stack, heap, bss, initialized data segment, text segment

A

stack: memory for local variables/function arguments, return address of current function. managed by compiler.

heap: memory region for dynamically allocated variables (not known at compile time, malloc, calloc, realloc, free)

bss: (blank started by symbol) memory region initialized to 0. store uninitialized global/static variables. managed by OS

initialized data segment: memory region for initialized data (global/static variables) known at compile time.

text segment: read-only memory region for machine code and constants (size of the stack or heap)

122
Q

Static

A

function/variable restricted to same file it is defined in.

funcs are global by default.

123
Q

Interface VS implementation

A

Interface: Blueprint portraying how a function should be implemented later.

Implementation Software “around” the interface/blueprint. defining the function’s implementation.

124
Q

API

A

Application Programming Interface.

code that enables two software programs to communicate

125
Q

Shell commands:

What do ar, nm and objdump do?

A

ar: create, modife, extract archives (file holding other files called “members of an archive”)

nm: list symbols from object files.

objdump: display information from object files.

126
Q

Software Build process from c sources to running program:

A
  • preprocessor strips .c file into commentless .i (preprocessed) file, runs macros

-compiler converts .i code into assembly .s file.

-linker performs symbol resolution, relocation, links object files together into single relocateable file.

  • locater takes relocateable file and linker script file, converts into executeably binary image.
127
Q

What does extern do in C?

A

Declares variable to be linked externally

128
Q

Recreate the Bursa program

A

void Bursa(int arr[], int size, int* bursa_arr)
{
int test_buy_i = 0;
int test_sell_i = 0;
int i;

for(i=1; i<size; ++i)
{
    if(arr[i] > arr[test_sell_i])
    {
        test_sell_i = i;
    }
    if(arr[i] < arr[test_buy_i])
    {
        test_sell_i = i;
        test_buy_i = i;
    }
    if((arr[test_sell_i] - arr[test_buy_i]) > bursa_arr[2])
    {
        bursa_arr[0] = test_buy_i;
        bursa_arr[1] = test_sell_i;
        bursa_arr[2] = (arr[test_sell_i] - arr[test_buy_i]);
    }

}

}

129
Q

Which variables initialize automatically?

A

global+static variables, initialized by bss at load time, assigning constants like 0.

130
Q

actual type of size_t?

A

long unsigned int. defined in stdlib.h

131
Q

What is a symbol?

A

Anything with a global or module level name.

132
Q

In a make file, what are these?

CC = gcc
CFLAGS = -Wall -Wextra -pedantic
DEBUG_FLAGS = -g
RELEASE_FLAGS = -O2

TARGET = fooer.out
OBJS = foo.o main.o

A

CC: program for compiling C program

CFLAGS: flags, to give to c preprocessor

DEBUG_FLAGS: for printing debug data

RELEASE_FLAGS: at optimization level 2. function inlining (replace functiion calls with code) dead code elimination (unexecuted code yeetus) and constant folding (replace constants with actual values)

TARGET: name of the file you want to create

OBJECT: list of all object file names

133
Q

In a make file, explain these:

.PHONY: all
all: main.c foo.c
$(CC) -o fooer.out main.c foo.c $(CFLAGS).

foo.o: foo.c
$(CC) -c foo.c $(CFLAGS).

clean :
rm edit $(objects)

debug :
make –debug

A

all is never a made result,

targeting all, requiring main.c and foo.c
create (-o) output file with specified name fooer.out using main.c and foo.c and add the CFLAGS

targeting foo.o: requiring foo.c,
compile without linker (-c) (generates .o file)

targeting phony clean: no requirements,
delete listed objects

targeting phony debug: no requirements
run first make command with debug mode

134
Q

implicit rule in makefile

A

even without adding rules, rules are implied (assume don’t run make command if missing objects or missing command requirements)

135
Q

phony targets in makefile

A

fake targets to permit the command to run even if there is a file with the target name. avoids file conflicts.

136
Q

What is Python

A

general purpose, high level (close to human) programming language.

emphasizes:
readability,
object oriented,
dynamically typed,
garbage collection,
easy to learn,
free,
open source.

137
Q

Interpreted VS Compiled Language

A

interpreted language is not converted to machine code before execution. instead interpreter reads line-by-line and executes

compiled language is compiled to machine code then executed

138
Q

Dynamic VS static Typing

A

dynamic typing: infer variable type from assigned value. python does this.

static: must declare variable type then assign a value

139
Q

Read-Eval-Print Loop

and Python Console

A

REPL: environment that can evaluate and print results of input expressions

Python Console is a REPL for python

140
Q

Primitive Types of Python

cast them

A

fundamental data types of python programs:

int(Integer), float(Floats), str(String), and bool(Booleans)

141
Q

Python References

A

objects that point to other objects

x = 10

“x” is a name object that points to the object “10”

142
Q

Python Virtual Machine

A

manages runtime environment,

loads and executes python bytecode (given by CPython interpreter)

allows python to run on any machine that has PVM,

provides memory management, garbage collection and exception handling services.

143
Q

Python Bytecode

A

low-level platform-dependant representation of python source code. (.pyc)

or generated by CPython interpreter, to be executed by PVM

144
Q

Python Memory Management:
CPython
Block
Pool
Arena
Reference Counting
Garbage Collection

A

MM: allocating/freeing memory for variables/data structures
CPython iterpreter, implements generational garbage collector and reference counting
Block: fixed size block of memory size multiple of 8 bytes
Pool: 4kb of memory containing blocks
Arena: 256kb of memory containing pools
Reference Counting: tracking number of references to objects. object freed if 0.
Garbage Collection: automatically frees memory for objects no longer in use

145
Q

define a function that prints the type of an object in python

A

def func(obect):
print( “” + str( def( object ) ) )

146
Q

what do break, continue and pass do in python

A

break: terminates current loop, resume at next execution

continue: skip current loop iteration, resume at next iteration

pass: nothing. placeholder to be replaced with something useful.

147
Q

python range()

A

for i in range(0,10,2)
print( “even: “ + str(i) )

range(start, stop, step)

148
Q

4 differences between python and C?

A

python: interpreted, dynamically typed, object-oriented, high level language

C: compiled, statically typed, procedural (function-oriented), low level language

149
Q

What is an interpreter? for python?

A

Reads/executes code. For CPython, reads and translates line by line into AST, bytecode, and lets PVM execute.

150
Q

Explain the steps python source code goes through to become executable code

A

CPython interpreter parses source to abstract syntax tree (so that the compiler can understand)
CPython interepreter generates bytecode for each node in the AST (which tells PVM what to do with the data)
Python Virtual Machine loads and executes the bytecode

151
Q

How does python manage memory

A

into arena of 256kb, pools of 4kb, and blocks of bytes size multiple of 8.