Skip to content

Commit

Permalink
added concrete example to readme
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Läufer <[email protected]>
  • Loading branch information
klaeufer committed Sep 1, 2023
1 parent 9b99c50 commit c4e6c97
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,78 @@
This is a Scala-based solution to the
[process tree homework assignment](http://osdi.etl.luc.edu/homework/home-lab-assignment-1)
from the course
[COMP 374/410: Introduction to Operating Systems](http://osdi.etl.luc.edu).
[COMP 374/410: Introduction to Operating
Systems](http://osdi.etl.luc.edu).

In short, this program converts a flat list of current processes, as printed by the `ps` command

```
> ps -ef
UID PID PPID C STIME TTY TIME CMD
0 1 0 0 24Aug23 ?? 72:25.36 /sbin/launchd
0 102 1 0 24Aug23 ?? 26:34.38 /usr/libexec/logd
0 103 1 0 24Aug23 ?? 0:01.08 /usr/libexec/smd
...
502 60706 60704 0 10:53PM ?? 0:02.27 /Applications/WhatsApp.app/...
...
502 65138 735 0 10:48AM ?? 0:23.83 /Applications/Microsoft Edge.app/...
...
```

to a hierarchical process tree, as printed by the `pstree` command (you'd usually have to install this through your package manager).

```
> pstree
-+= 00001 root /sbin/launchd
|--= 00102 root /usr/libexec/logd
|--= 00103 root /usr/libexec/smd
.
.
.
|-+= 00735 laufer /Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge
| |--- 65138 laufer /Applications/Microsoft Edge.app/Contents/Frameworks/Microsoft Edge
.
.
.
|-+= 60704 laufer /Applications/WhatsApp.app/...
| |--- 60706 laufer /Applications/WhatsApp.app/...
.
.
.
```


# Usage

To run the tests:

$ sbt test
```
$ sbt test
```

To run the main methods:

$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.mutable.Main"
$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.groupby.Main"
$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.fold.Main"
```
$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.mutable.Main"
$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.groupby.Main"
$ ps -ef | sbt "runMain edu.luc.etl.osdi.processtree.scala.fold.Main"
```

To generate larger data sets for testing:

$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fakeps.Main 100000" > data.txt
```
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fakeps.Main 100000" > data.txt
```

To run the benchmarks:

$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fakeps.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.mutable.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.groupby.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fold.Benchmark"
```
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fakeps.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.mutable.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.groupby.Benchmark"
$ sbt "test:runMain edu.luc.etl.osdi.processtree.scala.fold.Benchmark"
```

On Windows, if you installed [Git](http://git-scm.com/) with the recommended
third option, *Use Git and optional Unix tools from the Windows Command Prompt*,
then you will have a `ps` command available.
then you will have a `ps` command available.

0 comments on commit c4e6c97

Please sign in to comment.