๐Ÿ“— -> 01/16/26: ECS150-L6


Lecture 3
Lec 4

๐ŸŽค Vocab

โ— Unit and Larger Context

Discussion:

  • Covering project 1.2

Lect:

  • Sys Calls and Signals
  • file_descriptors.c - Demo, showing file descriptors
    • Linux, everything is a file. Writing to term echo hello > dev/pts/23
      • Inside /proc/617894/fd/ ?
    • He also includes file_descriptors.txtto describe the code in words
  • Starting on lec4, OS structure

โœ’๏ธ -> Scratch Notes

Signals

Form of interprocess communication (IPC)
About 30 diff signals (man 7 signals)

OS Structure

Apps:

User function calls, by programmers (int main type things)

Libraries (in C)

Declaration:

  • via standard headers
    Definition
  • pre compiled objects (libc.so.6, libc.a, libm.so)
  • input to linker (gcc -lc -lm)
    Code inclusion
  • included in exec directly (gcc -static)
  • or resolved at load-time

Compilation

GCC can pre-process, compile, assemble and link together

  • Preprocessor (cpp) transform program before compilation
    • .c -> .i
    • script.i
  • Compiler (cc) compiles a program into assembly code
    • .i -> .s
      • Assembly, readable but obtuse
    • script.s
  • Assembler (as) compiles assembly code into relocatable object file
    • .s -> .o
      • Binary, not human readable
    • script.o
  • Linker (ld) links object files into an executable
    • script (or a.out)
Linking

Generally loaded dynamically (unless compiled statically)
Can check dependencies:
$ ldd a.out # outputs libraries it needs

Aside: .so files are shared object files. They are compiled library files. The same as Windows DLL

Dynamic:

$ gcc cos.c -lm
$ ldd a.out
	libm.so.6
	libc.so.6
	/lib64/ld-linux-x86-64.so.2
$ ls -sh a.out
16K a.out
$ ./a.out 2.0 
-0.416147

Static

$ gcc -static cos.c -lm 
$ ldd a.out 
not a dynamic executable 
$ ls -sh a.out 
852K a.out 
$ ./a.out 2.0 
-0.416147

Static compilation MASSIVELY increased the file size

๐Ÿงช -> Refresh the Info

Did you generally find the overall content understandable or compelling or relevant or not, and why, or which aspects of the content were most novel or challenging for you and which aspects were most familiar or straightforward?)

Did a specific aspect of the content raise questions for you or relate to other ideas and findings youโ€™ve encountered, or are there other related issues you wish had been covered?)

Resources

  • Put useful links here

Connections

  • Link all related words