Skip to content

Commit

Permalink
add more notes in computer architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
kekeandzeyu committed Oct 3, 2024
1 parent f26fafa commit 746a4f3
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions Writerside/topics/Computer-Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ struct hello {

<p>sizeof(hello) = 16</p>

<p>Imporvement:</p>
<p>Improvement:</p>

<code-block lang="c" collapsible="true">
struct hello {
Expand All @@ -822,27 +822,27 @@ struct hello {

<p>sizeof(hello) = 12</p>

### 4 C Memory Layout
### 3 C Memory Layout

<p>Program's <format color="OrangeRed" style="italic">address space
</format> contains 4 regions: </p>
<list>
<li>
<p><format color="Fuchsia">Stack:</format> local variables,
grow downwards.</p>
<p><format color="Fuchsia">Stack:</format> local variables,
grow downwards.</p>
</li>
<li>
<p><format color="Fuchsia">Heap:</format> space requested via
<code>malloc()</code> and used with pointers; resizes dynamically,
grow upward.</p>
<p><format color="Fuchsia">Heap:</format> space requested via
<code>malloc()</code> and used with pointers; resizes dynamically,
grow upward.</p>
</li>
<li>
<p><format color="Fuchsia">Static Data:</format> global or
static variables, does not grow or shrink.</p>
<p><format color="Fuchsia">Static Data:</format> global or static
variables, does not grow or shrink.</p>
</li>
<li>
<p><format color="Fuchsia">Code:</format> loaded when program
starts, does not change.</p>
<p><format color="Fuchsia">Code:</format> loaded when program
starts, does not change.</p>
</li>
</list>

Expand All @@ -852,25 +852,25 @@ starts, does not change.</p>

<list>
<li>
<p><format color="Fuchsia">Declared outside a function:
</format> Static Data</p>
<p><format color="Fuchsia">Declared outside a function:
</format> Static Data</p>
</li>
<li>
<p><format color="Fuchsia">Declared inside a function:
</format> Stack</p>
<p><format color="Fuchsia">Declared inside a function:
</format> Stack</p>
<list type="bullet">
<li>
<p><code>main()</code> is a function.</p>
<p><code>main()</code> is a function.</p>
</li>
<li>
<p>freed when function returns.</p>
<p>freed when function returns.</p>
</li>
</list>
</li>
<li>
<p><format color="Fuchsia">Dynamically allocated (i.e.,
<code>malloc</code>, <code>calloc</code> & <code>realloc</code>):
</format> Heap.</p>
<p><format color="Fuchsia">Dynamically allocated (i.e.,
<code>malloc</code>, <code>calloc</code> & <code>realloc</code>):
</format> Heap.</p>
</li>
</list>

Expand Down

0 comments on commit 746a4f3

Please sign in to comment.