What even is a
systems programming language?
1970s:Improving on
Assembly
"A system program is
an integrated set of
subprograms ...
exceeding some
threshold of size
and/or
complexity."
Systems Programming Languages
(Bergeron et al. 1972)
1970s:
- The system program is likely to be used to support other software programs.
- It is designed for continued “production” use rather than a one-shot solution to a single
applications problem.
1970s:
A language which can be used without undue concern
for bit twiddling.
1990s:Rise
of Scripting languages
1990s:
Rise of Scripting languages
- Bash, languages like Perl, Python, Ruby, Javascript etc. worked their way into
the mainstream.
- Systems programming languages designed to build more primitive computer elements.
- Scripting languages are designed for gluing.
2010s:Boundaries
Blur
2010s:
Boundaries Blur
- Dropbox was able to build surprisingly large and scalable systems on just Python.
- Javascript is used to render real-time, complex UIs in billions of web pages.
- Gradual typing has gained steam in Javascript, Python, etc. enabling a transition from
“prototype” code to “production” code.
What is a systems
programming language today?
Where does Rust
shine?
Systems programming is
programming where
you spend
more time
reading man
pages
than
reading the internet.
Writing our own strace!
System Calls!
Syscalls!
Around 330 system calls in Linux:
- File Access - creat, read,
write,
open, close, etc.
- Process Control - wait, waitpid
, kill, fork, etc.
- Network Access - socket, getsockopt
, listen, etc.
What happens when a syscall occurs?
What happens when a syscall occurs?
Making a syscall.
- Setup register with syscall number & parameters.
- Send a trap to kernel.
- Result stored in register.
What is strace?
- A diagnostic, debugging and instructional userspace utility for Linux.
- Invaluable for solving problems with programs for which the source is not readily
available.
What is strace?
fn main() {
println!("Hello RustConf!");
}
What is strace?
Writing our own strace.
- How to observe another process?
- How to trap a system call?
- How to fetch register values?
How to observe a process?
ptrace!!
How to observe a process?
let output = cmd.before_exec(ptrace::traceme());
let mut child = cmd.spawn();
How to trap a system call?
How to trap a system call?
ptrace(
Request::PTRACE_SYSCALL,
pid,
ptr::null_mut(),
ptr::null_mut(),
);
waitpid(pid, None);
How to fetch register values?
let res = ptrace::ptrace(
Request::PTRACE_GETREGS,
pid,
PT_NULL as *mut c_void,
&mut regs as *mut _ as *mut c_void,
);
Conclusion 😊
A Shoutout!
- Arshia Mufti
- Shalom Abete
- Hailey James-Sorenson
- Taylor James-Sorenson
- Carrie Wu
- Andrew Zuckerman
- Theo Constantinedes
- Charilaos Pipis
- Wassim Marrakchi
- Stephen Koo