GithubHelp home page GithubHelp logo

davidandradeduarte / os-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

OS API - from "How Computers Really Work" book, by Matthew Justice

C 76.12% Python 23.88%
system-call-analysis linux-kernel

os-api's Introduction

OS API - from "How Computers Really Work" book, by Matthew Justice

gcc -o newfile newfile.c
./newfile
cat file1.txt
Hello, file!
python3 newfile.py
cat file2.txt
Hello from Python!

Analysing system calls

strace ./newfile

C functions being used are wrappers to these system calls
3 - number of the file descriptor
13 - number of bytes written
0 - success exit code

openat(AT_FDCWD, "file1.txt", O_WRONLY|O_CREAT|O_TRUNC, 0644) = 3
write(3, "Hello, file!\n", 13)          = 13
close(3)

now the python's program

strace python3 newfile.py

the same system calls are being made, with the addition of others, since when running with python we're using the python standard libraries (which may be doing other system calls for other reasons), in addition to the python interpreter also being traced by strace

openat(AT_FDCWD, "file2.txt", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ioctl(3, TCGETS, 0xbedf5070)            = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(3, 0, [0], SEEK_CUR)            = 0
ioctl(3, TCGETS, 0xbedf5040)            = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(3, 0, [0], SEEK_CUR)            = 0
write(3, "Hello from Python!\n", 19)    = 19
close(3)

os-api's People

Contributors

davidandradeduarte avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.