Comments (10)
@Son-Typ Could you please have a look and see if you can fix this? Thanks!
from selfie.
A small test case would be useful. Is the number_of_written_characters
wrong? I tried compiling using ./selfie -c selfie.c -o selfie.m
and ./selfie -l selfie.m -m 42 -c selfie.c -o selfie2.m
and those are my results:
For main
:
- bootlevel 0: 185520 bytes generated with 42906 instructions and 13896 bytes of data
- bootlevel 1: 282792 bytes generated with 42906 instructions and 13896 bytes of data
For printf
:
- bootlevel 0: 184936 bytes generated with 42580 instructions and 14616 bytes of data
- bootlevel 1: 184936 bytes generated with 42580 instructions and 14616 bytes of data
The printf
branch generates the same number of bytes for both bootlevels which I would expect to make more sense.
What are the expected results?
from selfie.
@Son-Typ I can't reproduce the issue you are seeing for main
. I am on commit 0de776c.
What I actually meant is the character count, not the byte count. But we may have to check both.
Try: ./selfie -c selfie.c -S selfie.s
Should show more than a million characters in the assembly file but does not on the printf branch. I am on commit 0cbbb30.
from selfie.
I was on the same commits while conducting both tests.
Regarding the problem: The reason is actually quite simple. At bootlevel 0 we use the bootstrapping compiler's dprintf
to write into the file, while we use our own dprintf
at the other bootlevels. Clang's/GCC's dprintf
does not count the number of written characters in number_of_written_characters
while the printf
implementation in main
and our dprintf
implementation do count. We probably want to count the written characters inside direct_output
as dprintf
returns the number of written characters. In this case we would have to stop counting inside put_character
, which is a nasty side effect to begin with.
I tried ./selfie -l selfie.m -c selfie.c -S selfie.s
, i.e., disassembling at bootlevel 1, which resulted in the expected "selfie.m: 1901357 characters of assembly [...]".
from selfie.
We will work on it asap but since its family holidays it might take a little while. Will post here when we're done
from selfie.
Sure, that's fine. Thanks a lot for looking into this. I hope there is a clean solution.
from selfie.
We have suggested a solution to the problem (PR created already). It should be mentioned that this solution (counting using the return value of dprintf) is not thread-safe, however in order to make it thread-safe, due to the limitations of C* we would have to use local variables in every method that calls put_character and return those and continue to count. This would be tedious to implement as some of these methods already have return values that are used in other parts of the code (for example print format returning the index of the format string). Therefore this is our best suggestion.
from selfie.
@MartinGroesbacher I am actually not sure why you guys are concerned about thread safety. Are you worried about the concurrency assignments in the SE class?
from selfie.
We just wanted to point this out in case you eventually may want to use printf in a future concurrent project that uses selfie as a library. If this is ever the case, then one would have to adapt the implementation.
from selfie.
Got it! Thanks.
from selfie.
Related Issues (20)
- 11) Virtualization - Introductory Assignments
- Compiler warnings with GCC 10.2.0 HOT 3
- Docker Build on Mac
- Clean up gcc/clang toolchain in Dockerselfie image to support 32-bit and 64-bit x86 and RISC-V HOT 10
- `self-assembler` assignment results in timeout HOT 7
- ELF file integrity
- Grader: Replace `threads` task `shared-heap` with thread-safe task HOT 4
- Suggestion: -Werror when self-grading HOT 7
- Grader not terminating on plain selfie HOT 4
- Order in list of assignments out of sync HOT 1
- Inconsistent handling of unexpected symbol syntax errors HOT 4
- Compiler warnings with GCC 11.1.0 HOT 4
- Residual files in selfie root directory in the selfie docker image after machine build HOT 1
- Multiplatform AMD64/ARM64 Support HOT 2
- "palloc out of physical memory" problem with changed "make os" HOT 7
- modeler returns "maximum code size exceeded" or "4712 expected between -4096 and 4095" if code size is increased HOT 7
- 32-bit + mipster + self-self-self [+ gc] is failing HOT 1
- Naming the programming language C* causes some confusion HOT 1
- Collisions between student code and Rotor [cc24] HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from selfie.