Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignments: Introduce mini-libc assignment #209

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

razvand
Copy link
Contributor

@razvand razvand commented Mar 20, 2023

Mini-libc is a minimalistic standard C library (libc) implementation. It is meant to be used as a complete replacement for the system libc (glibc in Linux). This is why test programs are built with -nostinc, -nostlib, -fno-builtin options.

The actual library source code is part of the libc/ directory. It is to be compiled as a static library in the libc.a file.

A set of sample use cases, as C source files, are stored in the samples/ directory.

Tests are in the tests/ directory, both as source code and shell scripts.

The aim is to have a minimally functional libc with features such as:

  • string management
  • very basic memory support
  • POSIX file I/O (i.e. open(), read(), write())
  • basic printing (puts())
  • sleep functions

@razvand razvand added kind/new New content / item topic/software-stack Related to "Software Stack" chapter area/assignment Update to homework assignments labels Mar 20, 2023
@razvand razvand added this to the SO 2022-2023 sem 2 milestone Mar 20, 2023
Copy link
Contributor

@Alex-deVis Alex-deVis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few suggestions for the prompt of bash commands.

assignments/mini-libc/README.md Outdated Show resolved Hide resolved
assignments/mini-libc/README.md Outdated Show resolved Hide resolved
assignments/mini-libc/README.md Outdated Show resolved Hide resolved
assignments/mini-libc/libc/include/stdlib.h Outdated Show resolved Hide resolved
assignments/mini-libc/libc/include/string.h Outdated Show resolved Hide resolved
assignments/mini-libc/libc/include/sys/mman.h Outdated Show resolved Hide resolved
assignments/mini-libc/libc/include/sys/stat.h Outdated Show resolved Hide resolved
assignments/mini-libc/libc/include/unistd.h Outdated Show resolved Hide resolved
assignments/mini-libc/libc/io/close.c Outdated Show resolved Hide resolved
assignments/mini-libc/libc/io/truncate.c Outdated Show resolved Hide resolved
assignments/mini-libc/libc/mm/malloc.c Outdated Show resolved Hide resolved
assignments/mini-libc/libc/stat/fstat.c Outdated Show resolved Hide resolved
assignments/mini-libc/samples/buffered_io.c Outdated Show resolved Hide resolved
JunisvaultCo

This comment was marked as spam.

JunisvaultCo

This comment was marked as off-topic.

Copy link
Member

@teodutu teodutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance, things look good enough. The suggested changes are purely cosmetic, so focus on merging this ASAP.

content/assignments/mini-libc/README.md Outdated Show resolved Hide resolved
content/assignments/mini-libc/README.md Outdated Show resolved Hide resolved
content/assignments/mini-libc/README.md Outdated Show resolved Hide resolved
content/assignments/mini-libc/tests/memory/malloc.c Outdated Show resolved Hide resolved
fi

"$exec_file" &
PID=$!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I noticed that without an extra sleep less than 1 second added here (to account for the 1s sleep in the source file), the behaviour is unexpected, generating different results on different runs, not sure if it is a problem only on my end but the extra sleep generates a stable response on multiple runs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was also what I noticed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pufi656, @JunisvaultCo, I now understand the issue. Will be back with a fix, please then let me know if it works on your side.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razvand, can't it be also improved by using interruption signals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pufi656, @JunisvaultCo, please see if the updated version works for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pufi656, what about the othe malloc / mmap scripts?

Copy link

@vladtf vladtf Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razvand, I've checked with latest changes from this pr an right now only these 2 tests are failing:

test_multiple_malloc_free        ........................ failed ...  0
test_malloc_free_sequence        ........................ failed ...  0

I will check what is the cause, but probably the same.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, everything seems to be working fine, I should clean the remotes and check again.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razvand confirming all scripts regarding memory testing work fine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed as well

Copy link
Contributor

@molecula2788 molecula2788 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, only minor changes.

content/assignments/mini-libc/samples/open_close.c Outdated Show resolved Hide resolved
content/assignments/mini-libc/samples/open_close.c Outdated Show resolved Hide resolved
content/assignments/mini-libc/samples/stat.c Show resolved Hide resolved
content/assignments/mini-libc/samples/stat.c Outdated Show resolved Hide resolved
content/assignments/mini-libc/samples/stat.c Outdated Show resolved Hide resolved
content/assignments/mini-libc/samples/fstat.c Show resolved Hide resolved
content/assignments/mini-libc/samples/fstat.c Outdated Show resolved Hide resolved
Mini-libc is a minimalistic standard C library (libc) implementation. It
is meant to be used as a complete replacement for the system libc (glibc
in Linux). This is why test programs are built with `-nostinc`,
`-nostlib`, `-fno-builtin` options.

The actual library source code is part of the `libc/` directory. It is
to be compiled as a static library in the `libc.a` file.

A set of sample use cases, as C source files, are stored in the
`samples/` directory.

Tests are in the `tests/` directory, both as source code and shell
scripts.

The aim is to have a minimally functional libc with features such as:

- string management
- very basic memory support
- POSIX file I/O (i.e. `open()`, `read()`, `write()`)
- basic printing (`puts()`)
- sleep functions

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@upb.ro>
Signed-off-by: Ruxandra Grigorie <ruxi.grigorie@gmail.com>
Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
Signed-off-by: Adrian Șendroiu <molecula2788@gmail.com>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexandru Apostolescu <alexx.apostolescu@gmail.com>
Signed-off-by: Alex-Costin Puflene <alexpufi22@yahoo.com>
Signed-off-by: Vlad Tiftilov <vlad.tiftilov@yahoo.com>
Signed-off-by: Laurențiu Ursu <laurentiu.ursu2001@gmail.com>
Signed-off-by: Iulia-Silvia Plăiașu <isplaiasu@gmail.com>
@razvand razvand merged commit d01ab62 into open-education-hub:master Mar 24, 2023
@razvand razvand deleted the assignment-mini-libc branch March 24, 2023 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/assignment Update to homework assignments kind/new New content / item topic/software-stack Related to "Software Stack" chapter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants