<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2022F%3A_Tutorial_2</id>
	<title>Operating Systems 2022F: Tutorial 2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Operating_Systems_2022F%3A_Tutorial_2"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;action=history"/>
	<updated>2026-04-06T00:11:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24071&amp;oldid=prev</id>
		<title>Soma: /* C: Examining the runtime memory map */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24071&amp;oldid=prev"/>
		<updated>2022-09-24T20:23:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;C: Examining the runtime memory map&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:23, 24 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l87&quot;&gt;Line 87:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 87:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs?  What happens if you run &quot;setarch &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;x86-64 &lt;/del&gt;-R 3000memview&quot; (&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;where &lt;/del&gt;3000memview is &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the name of the compiled program&lt;/del&gt;)&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;? &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs?  What happens if you run &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the program with the command &lt;/ins&gt;&quot;setarch -R &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;./&lt;/ins&gt;3000memview&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;?  &lt;/ins&gt;(&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note this changes how &lt;/ins&gt;3000memview is &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;run.&lt;/ins&gt;)  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24070&amp;oldid=prev</id>
		<title>Soma: /* C: Examining the runtime memory map */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24070&amp;oldid=prev"/>
		<updated>2022-09-24T20:20:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;C: Examining the runtime memory map&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:20, 24 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l87&quot;&gt;Line 87:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 87:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs?  What happens if &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;then &lt;/del&gt;run &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;`&lt;/del&gt;setarch x86-64 -R 3000memview&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;`&lt;/del&gt;?  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs?  What happens if &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;you &lt;/ins&gt;run &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/ins&gt;setarch x86-64 -R 3000memview&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot; (where 3000memview is the name of the compiled program)&lt;/ins&gt;?  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24069&amp;oldid=prev</id>
		<title>Soma: /* C: Examining the runtime memory map */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24069&amp;oldid=prev"/>
		<updated>2022-09-24T20:19:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;C: Examining the runtime memory map&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:19, 24 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l87&quot;&gt;Line 87:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 87:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Why are the addresses inconsistent between runs&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;?  What happens if then run `setarch x86-64 -R 3000memview`&lt;/ins&gt;?  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24044&amp;oldid=prev</id>
		<title>Soma: /* B: Comparing C and assembly */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24044&amp;oldid=prev"/>
		<updated>2022-09-17T19:35:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;B: Comparing C and assembly&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:35, 17 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l65&quot;&gt;Line 65:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 65:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Resources on x86-64 assembly language:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Resources on x86-64 assembly language:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://cs61.seas.harvard.edu/site/2018/Asm1/ Eddie Kohler&#039;s assembly language basics (2018)]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://cs61.seas.harvard.edu/site/2018/Asm1/ Eddie Kohler&#039;s assembly language basics (2018)] &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(also see other notes from this class)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax AT&amp;amp;T/GNU Assembler syntax]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax AT&amp;amp;T/GNU Assembler syntax]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI the Wikipedia article on calling conventions]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI the Wikipedia article on calling conventions]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24043&amp;oldid=prev</id>
		<title>Soma: /* B: Comparing C and assembly */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24043&amp;oldid=prev"/>
		<updated>2022-09-17T19:34:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;B: Comparing C and assembly&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:34, 17 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l59&quot;&gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Do the following with hello.c and syscall-hello.c, as before.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Do the following with hello.c and syscall-hello.c, as before.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A few tips on &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;reading &lt;/del&gt;assembly &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;code.  See [https&lt;/del&gt;:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;//en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax AT&amp;amp;T/GNU Assembler syntax] for more information on syntax and [https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI the Wikipedia article on calling conventions] for how functions are called.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A few tips on &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;x86-64 &lt;/ins&gt;assembly &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;language&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The last letter of many instructions refers to the size of the operand.  For example, callq means call a function using a &amp;quot;quad&amp;quot; value (64 bits).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The last letter of many instructions refers to the size of the operand.  For example, callq means call a function using a &amp;quot;quad&amp;quot; value (64 bits).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* A dollar sign preceding a value means that it is a literal value, a percent sign means it is a register.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* A dollar sign preceding a value means that it is a literal value, a percent sign means it is a register.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* If a register is in parentheses, then it is being used as a &amp;quot;pointer&amp;quot; (it contains an address, so the CPU goes to that address and interacts with the memory there).  If there is a number before the parentheses, it is an offset to the register&amp;#039;s value.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* If a register is in parentheses, then it is being used as a &amp;quot;pointer&amp;quot; (it contains an address, so the CPU goes to that address and interacts with the memory there).  If there is a number before the parentheses, it is an offset to the register&amp;#039;s value.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Resources on x86-64 assembly language:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [https://cs61.seas.harvard.edu/site/2018/Asm1/ Eddie Kohler&#039;s assembly language basics (2018)]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax AT&amp;amp;T/GNU Assembler syntax]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI the Wikipedia article on calling conventions]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Using the &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt; command, see what symbols are defined in prog-static and prog-dyn.  Which defines more symbols?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Using the &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt; command, see what symbols are defined in prog-static and prog-dyn.  Which defines more symbols?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24033&amp;oldid=prev</id>
		<title>Soma: /* A: Function calls, library calls, and system calls */</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24033&amp;oldid=prev"/>
		<updated>2022-09-16T13:56:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;A: Function calls, library calls, and system calls&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:56, 16 September 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l50&quot;&gt;Line 50:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 50:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Run &amp;lt;tt&amp;gt;ldd&amp;lt;/tt&amp;gt; on the static and dynamic versions of the program.  How does the output compare?  Why?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Run &amp;lt;tt&amp;gt;ldd&amp;lt;/tt&amp;gt; on the static and dynamic versions of the program.  How does the output compare?  Why?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# See what system calls prog-static produces by running &amp;lt;tt&amp;gt;strace -o syscalls-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more system calls?  &amp;#039;&amp;#039;&amp;#039;Note: system calls are saved in the log file syscalls-static.log.  Feel free to save them in a different file.&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# See what system calls prog-static produces by running &amp;lt;tt&amp;gt;strace -o syscalls-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more system calls?  &amp;#039;&amp;#039;&amp;#039;Note: system calls are saved in the log file syscalls-static.log.  Feel free to save them in a different file.&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# See what library calls prog-static produces by running &amp;lt;tt&amp;gt;ltrace -x &#039;*&#039; -o library-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more library calls?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# See what library calls prog-static produces by running &amp;lt;tt&amp;gt;ltrace -x &#039;*&#039; -o library-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more library calls? &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; (Note: you will have to run &amp;lt;tt&amp;gt;sudo apt install ltrace&amp;lt;/tt&amp;gt; to enable the command.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Compile the program dynamically but with &amp;quot;lazy&amp;quot; linking: &amp;lt;tt&amp;gt;gcc -O2 -z lazy prog.c -o prog-dynlazy&amp;lt;/tt&amp;gt;.  Run &amp;lt;tt&amp;gt;ltrace -o library-lazy.log ./prog-dynlazy&amp;lt;/tt&amp;gt;.  How does the output of this compare to that of the previous ltrace?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Compile the program dynamically but with &amp;quot;lazy&amp;quot; linking: &amp;lt;tt&amp;gt;gcc -O2 -z lazy prog.c -o prog-dynlazy&amp;lt;/tt&amp;gt;.  Run &amp;lt;tt&amp;gt;ltrace -o library-lazy.log ./prog-dynlazy&amp;lt;/tt&amp;gt;.  How does the output of this compare to that of the previous ltrace?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Use the command &amp;lt;tt&amp;gt;ls -l&amp;lt;/tt&amp;gt; to see the metadata associated with prog.c and prog-dyn, and prog-static.  Who owns these files?  What group are they in?  Do you notice any pattern with the permissions (rwx) associated with each file?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Use the command &amp;lt;tt&amp;gt;ls -l&amp;lt;/tt&amp;gt; to see the metadata associated with prog.c and prog-dyn, and prog-static.  Who owns these files?  What group are they in?  Do you notice any pattern with the permissions (rwx) associated with each file?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24023&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;In this tutorial we&#039;re going to look at how processes work at a low level: how they make system calls &amp; library calls, how C and assembly compare, and and how memory is laid out.  If you haven&#039;t already, please set up and use a VM on openstack for this work.  ==Background==  A process on UNIX-like systems are separated from each other: they run in their own address space - pointers can only refer to code and data in that program, not in other programs.  Because programs...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2022F:_Tutorial_2&amp;diff=24023&amp;oldid=prev"/>
		<updated>2022-09-12T00:54:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;In this tutorial we&amp;#039;re going to look at how processes work at a low level: how they make system calls &amp;amp; library calls, how C and assembly compare, and and how memory is laid out.  If you haven&amp;#039;t already, please set up and use a VM on openstack for this work.  ==Background==  A process on UNIX-like systems are separated from each other: they run in their own address space - pointers can only refer to code and data in that program, not in other programs.  Because programs...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In this tutorial we&amp;#039;re going to look at how processes work at a low level: how they make system calls &amp;amp; library calls, how C and assembly compare, and and how memory is laid out.  If you haven&amp;#039;t already, please set up and use a VM on openstack for this work.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
&lt;br /&gt;
A process on UNIX-like systems are separated from each other: they run in their own address space - pointers can only refer to code and data in that program, not in other programs.  Because programs are separated, they can&amp;#039;t access anything external to them without help.&lt;br /&gt;
&lt;br /&gt;
Here we&amp;#039;re going to talk about libraries and system calls, two ways programs gain access to additional functionality.  Libraries are for external code that is loaded into a process, while system calls allow for code in other processes or the OS kernel to be accessed.&lt;br /&gt;
&lt;br /&gt;
===Assembly Language===&lt;br /&gt;
&lt;br /&gt;
When we write code in C, it has to be compiled to machine code before it can be run.  This compilation step doesn&amp;#039;t happen all at once.  Compilation has distinct phases:&lt;br /&gt;
&lt;br /&gt;
* Compile C code into assembly code (.s files).&lt;br /&gt;
* Assemble assembly code into machine code placed in object code files (.o files).&lt;br /&gt;
* Link object code files together to create a runnable binary.&lt;br /&gt;
&lt;br /&gt;
If you run &amp;lt;tt&amp;gt;gcc -v&amp;lt;/tt&amp;gt;, you&amp;#039;ll see these steps all happen in a very verbose fashion.&lt;br /&gt;
&lt;br /&gt;
===Static &amp;amp; Dynamic Libraries===&lt;br /&gt;
&lt;br /&gt;
Most applications are not self contained; they rely on lots of external code.  In compiled languages such as C, external code can be brought into the process through &amp;#039;&amp;#039;&amp;#039;linking&amp;#039;&amp;#039;&amp;#039;.  There are two basic types of linking, static and dynamic linking:&lt;br /&gt;
* With &amp;#039;&amp;#039;&amp;#039;static linking&amp;#039;&amp;#039;&amp;#039;, code is brought in at compile time (specifically, in the link stage) and added to the executable.  The code is now the same as other application code.  (Static libraries are just collections of .o files.)&lt;br /&gt;
* With &amp;#039;&amp;#039;&amp;#039;dynamic linking&amp;#039;&amp;#039;&amp;#039;, a reference to the library code is added to the binary.  The actual library code has to later be loaded when the program is executed.  This loading will happen before &amp;lt;tt&amp;gt;main()&amp;lt;/tt&amp;gt; is called.&lt;br /&gt;
Static and dynamic libraries are stored in /lib and /usr/lib, traditionally.&lt;br /&gt;
&lt;br /&gt;
The dynamic libraries associated with a program binary can be found using the &amp;lt;tt&amp;gt;ldd&amp;lt;/tt&amp;gt; command.  You can use &amp;lt;tt&amp;gt;ltrace&amp;lt;/tt&amp;gt; to see calls to functions that are dynamically linked.  If a program is statically linked &amp;lt;tt&amp;gt;ldd&amp;lt;/tt&amp;gt; will have nothing to report and will generally produce an error.&lt;br /&gt;
&lt;br /&gt;
Note that code in static and dynamic libraries runs inside of the process loading the code; thus, library code has the same privileges as other application code.  It can do everything regular application code can do (it can access all of your code and data), but it can do no more than your code can do (it has the same restrictions on accessing system resources).&lt;br /&gt;
&lt;br /&gt;
===System Calls===&lt;br /&gt;
&lt;br /&gt;
A process on its own has limited access to the system.  It cannot directly access any external devices or data sources (e.g., files, keyboard, the screen, networks) on its own.  To access these external resources, to allocate memory, or otherwise change its runtime environment, it must make &amp;#039;&amp;#039;&amp;#039;system calls&amp;#039;&amp;#039;&amp;#039;.  Note that system calls run code outside of a process and thus cannot be called like regular function calls.  The standard C library provides function wrappers for most commonly-used system calls so they can be accessed like regular C functions.  Under the hood, however, these functions make use of special compiler directives in order to generate the machine code necessary to invoke system calls.&lt;br /&gt;
&lt;br /&gt;
You can see the system calls produced by a process using the &amp;lt;tt&amp;gt;strace&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
In general, the code you call through a system call has more privileges than regular application code.  This is because a system call is a request to the operating system kernel to do something on behalf of the process, and the kernel has full privileges to the system.  (Indeed, it is the part of the system that implements the process abstraction.)  We&amp;#039;re going to talk a lot about system calls this semester, this is just your introduction to the concept.&lt;br /&gt;
&lt;br /&gt;
==Tasks==&lt;br /&gt;
&lt;br /&gt;
===A: Function calls, library calls, and system calls===&lt;br /&gt;
&lt;br /&gt;
For [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/tut1/hello.c hello.c] and [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/tut1/syscall-hello.c syscall-hello.c] do the following (&amp;lt;b&amp;gt;substituting the appropriate source file for prog.c&amp;lt;/b&amp;gt;). For example, for hello.c, you would replace all instances of &amp;quot;prog&amp;quot; in a command with &amp;quot;hello&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
To download programs to your VM, use the wget command, e.g.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget https://homeostasis.scs.carleton.ca/~soma/os-2017f/code/tut1/hello.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Compile the program prog.c using &amp;lt;tt&amp;gt;gcc -O2 prog.c -o prog-dyn&amp;lt;/tt&amp;gt; and run prog-dyn.  What does it do?&lt;br /&gt;
# Statically compile and optimize prog.c by running &amp;lt;tt&amp;gt;gcc -O2 -static prog.c -o prog-static&amp;lt;/tt&amp;gt;.  How does the size compare with &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt;?&lt;br /&gt;
# Run &amp;lt;tt&amp;gt;ldd&amp;lt;/tt&amp;gt; on the static and dynamic versions of the program.  How does the output compare?  Why?&lt;br /&gt;
# See what system calls prog-static produces by running &amp;lt;tt&amp;gt;strace -o syscalls-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more system calls?  &amp;#039;&amp;#039;&amp;#039;Note: system calls are saved in the log file syscalls-static.log.  Feel free to save them in a different file.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
# See what library calls prog-static produces by running &amp;lt;tt&amp;gt;ltrace -x &amp;#039;*&amp;#039; -o library-static.log ./prog-static&amp;lt;/tt&amp;gt;.  Do the same for &amp;lt;tt&amp;gt;prog-dyn&amp;lt;/tt&amp;gt;.  Which version generates more library calls?&lt;br /&gt;
# Compile the program dynamically but with &amp;quot;lazy&amp;quot; linking: &amp;lt;tt&amp;gt;gcc -O2 -z lazy prog.c -o prog-dynlazy&amp;lt;/tt&amp;gt;.  Run &amp;lt;tt&amp;gt;ltrace -o library-lazy.log ./prog-dynlazy&amp;lt;/tt&amp;gt;.  How does the output of this compare to that of the previous ltrace?&lt;br /&gt;
# Use the command &amp;lt;tt&amp;gt;ls -l&amp;lt;/tt&amp;gt; to see the metadata associated with prog.c and prog-dyn, and prog-static.  Who owns these files?  What group are they in?  Do you notice any pattern with the permissions (rwx) associated with each file?&lt;br /&gt;
# (optional) Look up the documentation for each of the system calls made by the static versions of the programs.  You may need to append a 2 or 3 to the manpage invocation, e.g. &amp;quot;man 2 write&amp;quot; gets you the write system call documentation.&lt;br /&gt;
&lt;br /&gt;
===B: Comparing C and assembly===&lt;br /&gt;
&lt;br /&gt;
Do the following with hello.c and syscall-hello.c, as before.&lt;br /&gt;
&lt;br /&gt;
A few tips on reading assembly code.  See [https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax AT&amp;amp;T/GNU Assembler syntax] for more information on syntax and [https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI the Wikipedia article on calling conventions] for how functions are called.&lt;br /&gt;
* The last letter of many instructions refers to the size of the operand.  For example, callq means call a function using a &amp;quot;quad&amp;quot; value (64 bits).&lt;br /&gt;
* A dollar sign preceding a value means that it is a literal value, a percent sign means it is a register.&lt;br /&gt;
* If a register is in parentheses, then it is being used as a &amp;quot;pointer&amp;quot; (it contains an address, so the CPU goes to that address and interacts with the memory there).  If there is a number before the parentheses, it is an offset to the register&amp;#039;s value.&lt;br /&gt;
&lt;br /&gt;
# Using the &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt; command, see what symbols are defined in prog-static and prog-dyn.  Which defines more symbols?&lt;br /&gt;
# Run the command &amp;lt;tt&amp;gt;gcc -c -O2 prog.c&amp;lt;/tt&amp;gt; to produce an object file.  What file was produced?  What symbols does it define?&lt;br /&gt;
# Look at the assembly code of the program by running &amp;lt;tt&amp;gt;gcc -S -O2 prog.c&amp;lt;/tt&amp;gt;.  What file was produced?  Identify the following in the assembly code (if present):&lt;br /&gt;
#* A function call (call)&lt;br /&gt;
#* A return from a function (ret)&lt;br /&gt;
#* Registers being saved onto the stack (push)&lt;br /&gt;
#* Registers being retrieved from the stack (pop)&lt;br /&gt;
#* Subtraction (sub)&lt;br /&gt;
#* A system call (syscall)&lt;br /&gt;
# Disassemble the object file using &amp;lt;tt&amp;gt;objdump -d&amp;lt;/tt&amp;gt;.  How does this disassembly compare with the output from gcc -S?&lt;br /&gt;
# Examine the headers of object file, dynamically linked executable, and the statically linked executable using &amp;lt;tt&amp;gt;objdump -h&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Examine the contents of object file, dynamically linked executable, and the statically linked executable using &amp;lt;tt&amp;gt;objdump -s&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Re-run all of the previous gcc commands adding the &amp;quot;-v&amp;quot; flag.  What is all of that output?&lt;br /&gt;
&lt;br /&gt;
===C: Examining the runtime memory map===&lt;br /&gt;
&lt;br /&gt;
Compile and run [https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c], then consider the following questions.&lt;br /&gt;
# Why are the addresses inconsistent between runs?&lt;br /&gt;
# Roughly where does the stack seem to be?  The heap?  Code?  Global variables?&lt;br /&gt;
# Observe how the heap grows (i.e. the value of sbrk changes) in response to malloc calls.  Would you expect the heap to ever run into the stack?  Why or why not?&lt;br /&gt;
# Change each malloc call to allocate more than 128K.  What happens to the values of sbrk?  Why?  (Hint: use strace)&lt;br /&gt;
# Add more code and data to the program, and add more printf&amp;#039;s to see where things are.  Are things where you expect them to be?&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
===[https://homeostasis.scs.carleton.ca/~soma/os-2017f/code/tut1/hello.c hello.c]===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[]) {&lt;br /&gt;
&lt;br /&gt;
        printf(&amp;quot;Hello world!\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===[http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/tut1/syscall-hello.c syscall-hello.c]===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/syscall.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
char *buf = &amp;quot;Hello world!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv) {&lt;br /&gt;
        size_t result;&lt;br /&gt;
&lt;br /&gt;
        /* &amp;quot;man 2 write&amp;quot; to see arguments to write syscall */&lt;br /&gt;
        result = syscall(SYS_write, 1, buf, 13);&lt;br /&gt;
&lt;br /&gt;
        return (int) result;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===[https://homeostasis.scs.carleton.ca/~soma/os-2019f/code/3000memview.c 3000memview.c]===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
char *gmsg = &amp;quot;Global Message&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
const int buffer_size = 100;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[], char *envp[])&lt;br /&gt;
{&lt;br /&gt;
        char *lmsg = &amp;quot;Local Message&amp;quot;;&lt;br /&gt;
        char *buf[buffer_size];&lt;br /&gt;
        int i;&lt;br /&gt;
        &lt;br /&gt;
        printf(&amp;quot;Memory report\n&amp;quot;);&lt;br /&gt;
        printf(&amp;quot;argv:      %lx\n&amp;quot;, (unsigned long) argv);&lt;br /&gt;
        printf(&amp;quot;argv[0]:   %lx\n&amp;quot;, (unsigned long) argv[0]);&lt;br /&gt;
        printf(&amp;quot;envp:      %lx\n&amp;quot;, (unsigned long) envp);&lt;br /&gt;
        printf(&amp;quot;envp[0]:   %lx\n&amp;quot;, (unsigned long) envp[0]);&lt;br /&gt;
&lt;br /&gt;
        printf(&amp;quot;lmsg:      %lx\n&amp;quot;, (unsigned long) lmsg);&lt;br /&gt;
        printf(&amp;quot;&amp;amp;lmsg:     %lx\n&amp;quot;, (unsigned long) &amp;amp;lmsg);&lt;br /&gt;
        printf(&amp;quot;gmsg:      %lx\n&amp;quot;, (unsigned long) gmsg);&lt;br /&gt;
        printf(&amp;quot;&amp;amp;gmsg:     %lx\n&amp;quot;, (unsigned long) &amp;amp;gmsg);&lt;br /&gt;
&lt;br /&gt;
        printf(&amp;quot;main:      %lx\n&amp;quot;, (unsigned long) &amp;amp;main);&lt;br /&gt;
&lt;br /&gt;
        printf(&amp;quot;sbrk(0):   %lx\n&amp;quot;, (unsigned long) sbrk(0));&lt;br /&gt;
        printf(&amp;quot;&amp;amp;buf:      %lx\n&amp;quot;, (unsigned long) &amp;amp;buf);&lt;br /&gt;
&lt;br /&gt;
        for (i = 0; i&amp;lt;buffer_size; i++) {&lt;br /&gt;
                buf[i] = (char *) malloc(4096);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        printf(&amp;quot;buf[0]:    %lx\n&amp;quot;, (unsigned long) buf[0]);&lt;br /&gt;
        printf(&amp;quot;sbrk(0):   %lx\n&amp;quot;, (unsigned long) sbrk(0));&lt;br /&gt;
        &lt;br /&gt;
        return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>