Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Purdue CS 252 Systems Programming Midterm Exams 2025-2026 Guide, Exams of Embedded Systems Programming

Purdue CS 252 Systems Programming Midterm Exams 2025-2026 Guide

Typology: Exams

2024/2025

Available from 06/11/2025

Fortis-In-Re
Fortis-In-Re 🇺🇸

1

(1)

2.3K documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Purdue CS 252 Systems Programming
Midterm Exams 2025-2026 Guide
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Purdue CS 252 Systems Programming Midterm Exams 2025-2026 Guide and more Exams Embedded Systems Programming in PDF only on Docsity!

Purdue CS 252 Systems Programming Midterm Exams 2025-2026 Guide

What are the difforent types of memory scclions? - ANSWEF-Tcxt Data BSS Heap Stack What is stored in texl?- ANSWEF-Instructions that run the program. What is stored in Data?- ANSWEF-Initialized global variables What is stored in BSS? - ANSWEFUninitialized global variables (initialized to 0 by default) What is stored in the heap?- ANSWER-Memory that was returned by malloc/new. It grows as you requesl more. [grows upwards] What is stored in the stack? - ANSWEFR-Local variables and return addresses. [grows downward] What are dynamic libraries? - ANSWER-They are libraries shared with ather processes. Each have their own text, data, bss. What is a program? - ANSWER-File in a special format that contains all necessary information to load and application and make it run. What are some examples of executable file formats? - ANS WERELF - Executable Link File (Linux) COFF - Common Object File Format (Windows) What are the different steps to build a program? - ANSWER-Editor, C preprocessor, Compiler, Optimizer, Assembler, Linker, Loader What does the preprocessor do? - ANSWER-Expands macros like #define and #include to generate a .i file. What does the compiler do? - ANSWER-Compiles the .i file, which generates assembly code into a.s file What does the assembler do? - ANSWER-Assembles the .s file into an object file .o What does the linker do? - ANSWE-Connect known libraries to the object file. Sets most of the addresses for objects and files. Won’l know aboul. shared objcets, so will be UNDEF. What does the loader (runtime linker) do? - ANSWEF-It takes the executable file, and allocated memory for the sections. Also fills in UNDEF sections. WII finally jump into entry point. What is the entry point of a program? - ANSWER start which will initialize values then jump into main. When main is done, it will call _exit. Why u: left and right objects are free in OC) time. boundary tags?- ANSWER-Allow for constant time coalescing since you can see if the What are the different types of memory allocation errors? - ANSWER-Memory Leaks, Premature Frees, Double Free, Wild Frees, Memory Smashing What causes memory leaks? - ANSWER-Leaks are objects in memory that are no longer being used but are not freed. Worse for 24/7 programs where they can accumulate quickly. Object * ob] = new Obj0; obj =new Ohbjecti // old object is leaked What causes premature frees? - ANSWER-Premature frees are caused when an object that is still in use by the program is freed. Can override the next/previous pointers in the free list, thus corrupling it. ?- ANSWER-Alver frecing an ahje 8 equal to NULL. Then, next time you try and modify the object you will crash at that line rather of premature fre How can we minimize the impe than later down the road. What causes a double free?- ANSWER-A double free is caused by fi already free. The object is added to the free list twice, thus corrupting it. ing an object that is What causes a wild free? - ANSWEF-Wild frees happen when a program attempts to free a pointer not returned by malloc. What is memory smashing? - ANS WERMemory smashing happens when less memory is allocated than the memory that will be used. Will overwrite header of next block, which can cause a crash. What is an operating system? - ANSWER-An OS is a program that sits in between the hardware and the user program. What kind of file system does UNIX have? - ANSWER Hierarchical file system What are some important directories? - ANSWER-/ - Root Directory /ete - OS Config files (passwd, groups) /dev - List of devices attached Aasr - Libraries and tools What is a dcamon? - ANSWER-Programs running in the background implementing a service (server). What is root? - ANSWER-User with special privileges to modify files anywhere in the system. What are the yellow pages? - ANSWER-In some systems, password and group files are stored in a server that makes management casicr. How are partitions divided? - ANSWER-Bool Block, Suporblock, Inede-list, Data Block What is in the boot block? - ANSWER-Block wilh small picce of code that tells the parution Lhe OS is going to start. Assume 1 Kb block and 256 block numbers in each index block. - ANSWER-Direct= 12 * 1Kb = 12Kb Single=3 * 255 * 1Kb = 768 Kb Double=1 * 256 * 256 * 1Kb = 64Mb Triple=1* 256 * 256 * 256 * 1Kb = 16Gb How is a directory represented? - ANSWER-File that contains list of pairs, (file name, Inode number). What is a hard link? - ANSWER-Connection between file name and Inode number). If file is renamed, link will stay. What is a soft link? - ANSWER-Pair: (file name, inode number-with-file-storing-path). Like shortcuts, can point to files in different partitions. No reference count, no increment/decrement. Tf file is renamed, link will break When does UNIX time start? - ANSWER-0:00 Jan 1, 1970 How are the permission bits separated in UNIX? - ANSWEICuser group other CWwX PWX WX How do you change the permission bits? - ANSWER-chmod <+|-> filename How to change bits on octal?- ANSWER-RWX RWX RWX 110110110 chmod 664 hello.c Makes file readable and writable by everyone. What is a directory bit?- ANSWER-File flag that indicated ifthe file is a directory. When a directory, the x flag determines if it can be listed. What properties does a process have? - ANSWER-PID: Index in process table Command and Arg Envy Variables Current. Dir Owner (UserID) Stdin/out/err What is a process id?- ANSWER-A PID is an integer that uniquely identifies processes among all live ones. What is command and arguments? - ANSWER-An array that contains the command run and all of the arguments given to it. Stored in argv What are environmental variables?- ANSWER-Array of strings that are inherited from the parent. Describe info about current shell. What docs ls do? - ANSWEF Is lists the files in a given directory. Flags: -al (list all including hidden & time stamps} -f (hide error messages) -R (recursive) What does grep do? - ANSWER-Prints lines that contain a pattern. What does man do?- ANSWEF-Prints the manual page related to that command Flags: -s (specify section) -k (all pages that contain word) Sections: 1. UNIX commands 2. System Calls 3. C Std Lib What docs whercis do? - ANSWER-Prints the path of where a [ile is located. What does which do? - ANSWEFR-Prints the path of the command that will be executed if “command” is typed. which ps Jusr/uch/ps whereis ps /usr/bin/ps Jusr/uch/ps What does head do?- ANSWERList the first 10 lines of a file by default, can be modified with - ( of lines) What does tail do?- ANSWER-List the last 10 lines of a file, can be modified same as head. Flags: -f (periodically print new additions to file). What does awk do?- ANSWER-Simple text manipulation, can print specific columns or words in a file. What does sed do? - ANSWER-Simple text processing sed/s/current/new/g hello.sh > hello2.sh Replaces all instances of current to new and redirects output to hello2.sh What does find do? - ANSWEF-Recursively descend directories seeking files that match an expression, then executed command on them. What is a shobang? - ANSWER-Codc at Lop of the file that says which shell will be exeenting the script. When does the mode switch? - ANSWER-lser modes can request that certain system calls be run in Kernel mode. The OS will switch to run, then return. Why separate the two modes?- ANSWEF-Security, Robustness, Fairness What is an interrupt?- ANSWER-An event that requires immediate attention. When received, the CPU will stop immediately and jump to the interrupt handler. Is polling syne or asyne? What about interrupt? - ANSWER-Polling - Synchronous Interrupt - Asynchronous What is an interrupt vector? - ANSWER-Array of points that point to different interrupt handlers for different interrupts. What are some types of interrupts?- ANSWER Device Interrupts (mouse moved, key types, etc) Math Exceptions (divide by 0) Page Faults (Virtual Memory page not loaded, invalid permission, etc) Software Interrupts What are system calls?- ANSWER-Way user programs request services from OS. Ex: open, read, write, fork They are done in kernel mode because of special access and security. What are the steps for the open system call?- ANSWER-Get file name and mode check if file exits verity all permissions ask disk to perform operation wait, return fd What happens if there is an crror wilh the system call? - ANSWER-The OS scts the global variable “errno” to the error number, can resolve with perror(s). What happens if the user calls write(fd, buff, n)- ANSWER-1. Write wrapper in libe generates a software interrupt The OS interrupt handler checks the arguments. Verifies that the file is opened in write, also checks ifrange is valid. OS tells the hard drive to write to the buffer. OS puts process in wait mode until complete Disk completes write and tells OS Puts in back into ready slatc and il is scheduled to complete