<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spenner2</id>
	<title>Soma-notes - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spenner2"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php/Special:Contributions/Spenner2"/>
	<updated>2026-05-12T21:32:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_8_Notes&amp;diff=17525</id>
		<title>COMP 3000 2012 Week 8 Notes</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_8_Notes&amp;diff=17525"/>
		<updated>2012-10-26T13:07:15Z</updated>

		<summary type="html">&lt;p&gt;Spenner2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Practice questions and their associated answers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: You can create a sparse file in UNIX by writing sequences of zeros to a file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: False.  Sparse file means holes. Zeroes aren&#039;t holes.&lt;br /&gt;
You need to move the file pointer. You have to use a&lt;br /&gt;
seek. The data will be READ as zeros, though...&lt;br /&gt;
Look up truncate command and strace it. It ain&#039;t just writing zeros&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: Are environment variables ``global variables? Specifically, if you change the value of an environment variable X in one process, what happens to the value of X in other processes?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A:Nothing happens. Env vars aren&#039;t globals. They&#039;re passed in with Execve. Environments&lt;br /&gt;
variables are typically process specific.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: In UNIX, there are three permissions associated with the user, the user&#039;s group, and everyone else. What are those three permissions? &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: rwx (Read, Write, Execute)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: If you see a zombie process during normal system operation, how can you get rid of it?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Kill the parent&lt;br /&gt;
Why? init will own the zombie process and then kill it&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: I can copy a file using I/O redirection as follows: cat /bin/ls &amp;gt; bar. If I now type ./bar, it won&#039;t run. However, if I run another command before typing ./bar, I will get &lt;br /&gt;
a file listing. What needed to be changed to get bar to run?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: chmod +x &lt;br /&gt;
Default non executable. Need to make it executable. (--x)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: System calls cannot normally be made using standard function calls. What CPU mechanism is used by regular processes to invoke kernel functionality?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Software interrupt. Signals are a form of of software interrupt.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;A system call is an entry point into the Linux kernel. Usually, system calls are not invoked directly: instead, most system calls have corresponding C library wrapper functions which perform the steps required (e.g., trapping to kernel mode) in order to invoke the system call. Thus, making a system call looks the same as invoking a normal library function.&amp;quot; from man 2 intro &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The call to the library function itself does not cause a switch to kernel mode (if the execution was not already in kernel mode) and is usually a normal subroutine call (using, for example, a &amp;quot;CALL&amp;quot; assembly instruction in some Instruction set architectures (ISAs)). The actual system call does transfer control to the kernel (and is more implementation-dependent and platform-dependent than the library call abstracting it). For example, in Unix-like  systems, &amp;quot;fork&amp;quot; and &amp;quot;execve&amp;quot; are C library functions that in turn execute instructions that invoke the &amp;quot;fork&amp;quot; and &amp;quot;execve&amp;quot; system calls. Making the system call directly in the application code is more complicated and may require embedded assembly code to be used (in C and C++) as well as knowledge of the low-level binary interface for the system call operation, which may be subject to change over time and thus not be part of the application binary interface; the library functions are meant to abstract this away.&amp;quot; from http://en.wikipedia.org/wiki/System_call&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: After a fork system call, what runs first, the child process runs or the parent process?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Don&#039;t know... Undefined. Can not depend on ordering&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Q: Signal handlers can be called at almost any point in a process&#039;s execution. (T/F)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: True. That&#039;s the purpose of signals&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Register a normal C function as a signal handler&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some are implemented by default (ex. sigkill)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals can be called at any point in execution.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;When a signal is sent, the operating system interrupts the target process&#039;s normal flow of execution. Execution can be &#039;&#039;&#039;interrupted during any non-atomic instruction.&#039;&#039;&#039; If the &#039;&#039;&#039;process has previously registered a signal handler, that routine is executed. Otherwise&#039;&#039;&#039; the default signal handler is executed.&amp;quot;  from http://en.wikipedia.org/wiki/Unix_signal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: System V init scripts run programs sequentially or in parallel?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Sequentially (sysV). Shell script that runs every &#039;&#039;command&#039;&#039; sequentially&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upstart does it in parallel though. This is the reason sysV is being replaced by Upstart. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: Without errors, what does the execve system call return? # Who calls a signal handler?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: On success, execve() does not return, on error -1 is returned, and errno is set appropriately.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program itself calls the signal handler&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What program is used to check the consistency of the data structures of a filesystem?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: fsck &amp;lt;- wrapper function&amp;lt;br&amp;gt;&lt;br /&gt;
fsck.FMT &amp;lt;- called by fsck for a specific format (ex: fsck.ext4)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What allocates the storage for environment variables and command-line arguments?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: The kernel. The kernel is the only thing that can allocate.(execve)&amp;lt;br&amp;gt;&lt;br /&gt;
This also makes sense because execve is a system call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: A file that has a logical size of one gigabyte but only takes up 100K on disk is called what kind of file in UNIX?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Sparse file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What is an easy (but not foolproof way) way to tell that you are running in a virtual environment on Linux? What command do you run to get this information?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: lspci, lshw.&amp;lt;br&amp;gt;&lt;br /&gt;
In /proc/, you may be able to also.&amp;lt;br&amp;gt;&lt;br /&gt;
These commands display the machine&#039;s &amp;quot;hardware&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not /dev/ because that&#039;s the abstraction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q:What is the purpose of the PATH environment variable?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: At the command line, the $PATH variable is where the shell looks for binaries/files.&lt;br /&gt;
The path is walked when the fullPATH/filename of the command line hasn&#039;t been specified &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: When would you expect ltrace to output more lines than strace? When should strace output more than ltrace?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Some libraries make no sys calls (strlen). Libraries that do basic string and math&lt;br /&gt;
operations -&amp;gt; no sys calls&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Programs with lots of I/O will use lot of sys calls&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What command is used to change the priority of a process? &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: nice and renice&amp;lt;br&amp;gt;&lt;br /&gt;
nicess is policy value (default value and you can modify this)&amp;lt;br&amp;gt;&lt;br /&gt;
priority (dynamic) is based on niceness and the amount of time the process has run on&lt;br /&gt;
cpu&amp;lt;br&amp;gt;&lt;br /&gt;
Priority doesn&#039;t apply to I/O. I/O will continue despite other processing having high&lt;br /&gt;
priority. I/O will always slow down the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What is the difference between a library call and a function call?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: The former requires a library card and a telephone.&lt;br /&gt;
&amp;lt;br&amp;gt; [[User:Spenner2|Spenner2]] ([[User talk:Spenner2|talk]])    nice&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spenner2</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_8_Notes&amp;diff=17524</id>
		<title>COMP 3000 2012 Week 8 Notes</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_8_Notes&amp;diff=17524"/>
		<updated>2012-10-26T13:05:34Z</updated>

		<summary type="html">&lt;p&gt;Spenner2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Practice questions and their associated answers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: You can create a sparse file in UNIX by writing sequences of zeros to a file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: False.  Sparse file means holes. Zeroes aren&#039;t holes.&lt;br /&gt;
You need to move the file pointer. You have to use a&lt;br /&gt;
seek. The data will be READ as zeros, though...&lt;br /&gt;
Look up truncate command and strace it. It ain&#039;t just writing zeros&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: Are environment variables ``global variables? Specifically, if you change the value of an environment variable X in one process, what happens to the value of X in other processes?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A:Nothing happens. Env vars aren&#039;t globals. They&#039;re passed in with Execve. Environments&lt;br /&gt;
variables are typically process specific.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: In UNIX, there are three permissions associated with the user, the user&#039;s group, and everyone else. What are those three permissions? &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: rwx (Read, Write, Execute)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: If you see a zombie process during normal system operation, how can you get rid of it?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Kill the parent&lt;br /&gt;
Why? init will own the zombie process and then kill it&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: I can copy a file using I/O redirection as follows: cat /bin/ls &amp;gt; bar. If I now type ./bar, it won&#039;t run. However, if I run another command before typing ./bar, I will get &lt;br /&gt;
a file listing. What needed to be changed to get bar to run?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: chmod +x &lt;br /&gt;
Default non executable. Need to make it executable. (--x)&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Q: System calls cannot normally be made using standard function calls. What CPU mechanism is used by regular processes to invoke kernel functionality?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Software interrupt. Signals are a form of of software interrupt.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;A system call is an entry point into the Linux kernel. Usually, system calls are not invoked directly: instead, most system calls have corresponding C library wrapper functions which perform the steps required (e.g., trapping to kernel mode) in order to invoke the system call. Thus, making a system call looks the same as invoking a normal library function.&amp;quot; from man 2 intro &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The call to the library function itself does not cause a switch to kernel mode (if the execution was not already in kernel mode) and is usually a normal subroutine call (using, for example, a &amp;quot;CALL&amp;quot; assembly instruction in some Instruction set architectures (ISAs)). The actual system call does transfer control to the kernel (and is more implementation-dependent and platform-dependent than the library call abstracting it). For example, in Unix-like  systems, &amp;quot;fork&amp;quot; and &amp;quot;execve&amp;quot; are C library functions that in turn execute instructions that invoke the &amp;quot;fork&amp;quot; and &amp;quot;execve&amp;quot; system calls. Making the system call directly in the application code is more complicated and may require embedded assembly code to be used (in C and C++) as well as knowledge of the low-level binary interface for the system call operation, which may be subject to change over time and thus not be part of the application binary interface; the library functions are meant to abstract this away.&amp;quot; from http://en.wikipedia.org/wiki/System_call&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: After a fork system call, what runs first, the child process runs or the parent process?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Don&#039;t know... Undefined. Can not depend on ordering&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Q: Signal handlers can be called at almost any point in a process&#039;s execution. (T/F)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: True. That&#039;s the purpose of signals&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Register a normal C function as a signal handler&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some are implemented by default (ex. sigkill)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Signals can be called at any point in execution.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;When a signal is sent, the operating system interrupts the target process&#039;s normal flow of execution. Execution can be &#039;&#039;&#039;interrupted during any non-atomic instruction.&#039;&#039;&#039; If the &#039;&#039;&#039;process has previously registered a signal handler, that routine is executed. Otherwise&#039;&#039;&#039; the default signal handler is executed.&amp;quot;  from http://en.wikipedia.org/wiki/Unix_signal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: System V init scripts run programs sequentially or in parallel?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Sequentially (sysV). Shell script that runs every &#039;&#039;command&#039;&#039; sequentially&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upstart does it in parallel though. This is the reason sysV is being replaced by Upstart. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: Without errors, what does the execve system call return? # Who calls a signal handler?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: execve DOES NOT RETURN ANYTHING. Process image is replaced.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program itself calls the signal handler&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What program is used to check the consistency of the data structures of a filesystem?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: fsck &amp;lt;- wrapper function&amp;lt;br&amp;gt;&lt;br /&gt;
fsck.FMT &amp;lt;- called by fsck for a specific format (ex: fsck.ext4)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What allocates the storage for environment variables and command-line arguments?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: The kernel. The kernel is the only thing that can allocate.(execve)&amp;lt;br&amp;gt;&lt;br /&gt;
This also makes sense because execve is a system call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: A file that has a logical size of one gigabyte but only takes up 100K on disk is called what kind of file in UNIX?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Sparse file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What is an easy (but not foolproof way) way to tell that you are running in a virtual environment on Linux? What command do you run to get this information?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: lspci, lshw.&amp;lt;br&amp;gt;&lt;br /&gt;
In /proc/, you may be able to also.&amp;lt;br&amp;gt;&lt;br /&gt;
These commands display the machine&#039;s &amp;quot;hardware&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not /dev/ because that&#039;s the abstraction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q:What is the purpose of the PATH environment variable?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: At the command line, the $PATH variable is where the shell looks for binaries/files.&lt;br /&gt;
The path is walked when the fullPATH/filename of the command line hasn&#039;t been specified &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: When would you expect ltrace to output more lines than strace? When should strace output more than ltrace?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: Some libraries make no sys calls (strlen). Libraries that do basic string and math&lt;br /&gt;
operations -&amp;gt; no sys calls&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Programs with lots of I/O will use lot of sys calls&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What command is used to change the priority of a process? &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: nice and renice&amp;lt;br&amp;gt;&lt;br /&gt;
nicess is policy value (default value and you can modify this)&amp;lt;br&amp;gt;&lt;br /&gt;
priority (dynamic) is based on niceness and the amount of time the process has run on&lt;br /&gt;
cpu&amp;lt;br&amp;gt;&lt;br /&gt;
Priority doesn&#039;t apply to I/O. I/O will continue despite other processing having high&lt;br /&gt;
priority. I/O will always slow down the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Q: What is the difference between a library call and a function call?&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A: The former requires a library card and a telephone.&lt;br /&gt;
&amp;lt;br&amp;gt; [[User:Spenner2|Spenner2]] ([[User talk:Spenner2|talk]])    nice&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spenner2</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_3_Notes&amp;diff=17356</id>
		<title>COMP 3000 2012 Week 3 Notes</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=COMP_3000_2012_Week_3_Notes&amp;diff=17356"/>
		<updated>2012-09-30T19:14:16Z</updated>

		<summary type="html">&lt;p&gt;Spenner2: /* Why we&amp;#039;re studying unix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shell ==&lt;br /&gt;
&lt;br /&gt;
* useful command line programs&lt;br /&gt;
** bc -l&lt;br /&gt;
*** command line calculator&lt;br /&gt;
** cal&lt;br /&gt;
*** command line calendar&lt;br /&gt;
** uniq&lt;br /&gt;
*** filters out duplicate lines&lt;br /&gt;
** sort&lt;br /&gt;
*** takes input on STDIN, sorts lines, prints to STDOUT&lt;br /&gt;
* vmlinux is the linux kernel with virtual memory {{ref|vmlinux}}&lt;br /&gt;
** vmlinuz is the same but compressed&lt;br /&gt;
* bash runs on vmlinux&lt;br /&gt;
** most programs run on bash&lt;br /&gt;
** ls/cd also run on vmlinux&lt;br /&gt;
** ls runs as a child process of bash&lt;br /&gt;
* to get rid of a misbehaving child&lt;br /&gt;
** the parent must kill it&lt;br /&gt;
** waits for child to die&lt;br /&gt;
** an unreaped child becomes a zombie&lt;br /&gt;
** zombies can&#039;t be killed, must be reaped&lt;br /&gt;
** to kill a zombie, must kill parent&lt;br /&gt;
** orphans become a child of init (ward of state)&lt;br /&gt;
** init is good at reaping children&lt;br /&gt;
&lt;br /&gt;
== job control ==&lt;br /&gt;
&lt;br /&gt;
* job is a process&lt;br /&gt;
** term comes from batch processing&lt;br /&gt;
* Useful control sequences&lt;br /&gt;
** Ctrl-C&lt;br /&gt;
*** terminate job&lt;br /&gt;
** Ctrl-Z&lt;br /&gt;
*** stop job&lt;br /&gt;
* To start a stopped job in the foreground&lt;br /&gt;
** fg %n&lt;br /&gt;
*** where n is the job number&lt;br /&gt;
* To start a stopped job in the background&lt;br /&gt;
** bg %n&lt;br /&gt;
* To determine jobs that are running&lt;br /&gt;
** jobs&lt;br /&gt;
* Who manages jobs?&lt;br /&gt;
** the shell&lt;br /&gt;
** built on kernel functionality&lt;br /&gt;
&lt;br /&gt;
== Why we&#039;re studying  &amp;lt;span style=&amp;quot;text-decoration:line-through;&amp;quot;&amp;gt;unix&amp;lt;/span&amp;gt; Linux based operating systems==&lt;br /&gt;
&lt;br /&gt;
* all operating systems have roughly the same architecture&lt;br /&gt;
* windows is just a variation on unix. Built and designed very similarily.&lt;br /&gt;
* &amp;quot;Like a different accent. Same everything, but renamed&amp;quot;&lt;br /&gt;
* Slight differences in the way things are done&lt;br /&gt;
** Example: On Unix, configs reside in flat text files. In Windows, they live in an opaque key/value store called the registry.&lt;br /&gt;
&lt;br /&gt;
Despite the similarities between OS families, Unix systems tend to be built much more transparently, which makes them a good vehicle to study OS topics&lt;br /&gt;
&lt;br /&gt;
* windows comes from vms&lt;br /&gt;
** increment(vms) -&amp;gt; wnt&lt;br /&gt;
&lt;br /&gt;
see [http://www.team.net/mjb/hawg.html Unix - The Hole Hawg].&lt;br /&gt;
&lt;br /&gt;
== Init and Shell Scripts ==&lt;br /&gt;
&lt;br /&gt;
Guest mini-lecture by Ann Fry&lt;br /&gt;
&lt;br /&gt;
* /etc/init.d/&lt;br /&gt;
* initialization scripts&lt;br /&gt;
* examples&lt;br /&gt;
** /etc/init.d/networking [start|stop]&lt;br /&gt;
** /etc/init.d/networking [start|stop]&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; &#039;&#039;command&#039;&#039; [ &#039;&#039;keyword1&#039;&#039; | &#039;&#039;keyword2&#039;&#039; | ... ] means to execute a command with an optional choice of two or more keywords.&lt;br /&gt;
* shell scripts&lt;br /&gt;
* start with&lt;br /&gt;
** #!/bin/bash&lt;br /&gt;
** #!/bin/csh&lt;br /&gt;
** #!/bin/ksh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Enter&#039;&#039; Anil Somayaji.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;[http://en.wikipedia.org/wiki/Exeunt Exeunt]&#039;&#039; Ann &#039;&#039;stage left&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Init scripts&lt;br /&gt;
* Traditional init scripts run sequentially&lt;br /&gt;
* Modern init scripts run in parallel&lt;br /&gt;
* executables&lt;br /&gt;
* ELF&lt;br /&gt;
* A file starting with #!&lt;br /&gt;
** next comes the path to an interpreter for the rest of the file&lt;br /&gt;
=== Common Directories ===&lt;br /&gt;
see [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and [http://www.pathname.com/fhs/pub/fhs-2.3.html FHS 2.3]&lt;br /&gt;
* /etc&lt;br /&gt;
** pronounced ett-see&lt;br /&gt;
** system wide configuration files&lt;br /&gt;
** different subdirectories and directory structures&lt;br /&gt;
** Competing Unix cultures apparent in the naming conventions and directory structures&lt;br /&gt;
** /etc/&amp;lt;prog&amp;gt;.conf&lt;br /&gt;
** /etc/&amp;lt;prog&amp;gt;/&lt;br /&gt;
** /etc/&amp;lt;prog&amp;gt;.d/&lt;br /&gt;
* /bin&lt;br /&gt;
** system binaries&lt;br /&gt;
** often this is local&lt;br /&gt;
** Bare minimum of what&#039;s needed to boot.&lt;br /&gt;
** Important for diskless systems (see /usr/) or think clients. &lt;br /&gt;
** Historically, we kept this as small as possible&lt;br /&gt;
* /lib&lt;br /&gt;
** system libraries&lt;br /&gt;
* /home&lt;br /&gt;
** user directories&lt;br /&gt;
* /usr&lt;br /&gt;
** often this is shared&lt;br /&gt;
** Historically, the /usr/ directory was a remote file system mounted after the system had fully booted. Servers had more disk space than terminals/thin clients.&lt;br /&gt;
** /usr/bin&lt;br /&gt;
** user binaries&lt;br /&gt;
** /usr/lib&lt;br /&gt;
** user libraries&lt;br /&gt;
&lt;br /&gt;
== History of Unix ==&lt;br /&gt;
&lt;br /&gt;
* In the beginning, there was AT&amp;amp;T&#039;s Unix&lt;br /&gt;
* AT&amp;amp;T gave site licenses with all the source&lt;br /&gt;
* Berkeley developed networking (at least TCP/IP) called BSD&lt;br /&gt;
** licensed under permissive BSD license&lt;br /&gt;
* AT&amp;amp;T forked System V&lt;br /&gt;
** Not permissively licensed&lt;br /&gt;
* Sun created hardware to run unix and forked SunOS from BSD&lt;br /&gt;
* Sun changed from SunOS (BSD) to Solaris (System V)&lt;br /&gt;
** people disliked this&lt;br /&gt;
* POSIX standard was an outcome of the fragmentation&lt;br /&gt;
* Free Software Foundation came out of the fragmentation&lt;br /&gt;
** founded by rms ([http://xkcd.com/225/ Richard] M. [http://www.youtube.com/watch?v=1sxNy0qQDkU Stallman])&lt;br /&gt;
** not initially a very open development environment&lt;br /&gt;
** built all the components of unix called GNU (GNU&#039;s Not Unix)&lt;br /&gt;
** yacc -&amp;gt; bison&lt;br /&gt;
** more -&amp;gt; less&lt;br /&gt;
** cc -&amp;gt; gcc&lt;br /&gt;
* Anil was sysadmin for a crystalography lab&lt;br /&gt;
** SGI IRX boxes&lt;br /&gt;
** ran IRIX&lt;br /&gt;
* 80386 came out&lt;br /&gt;
** capable of running a real unix because of virtual memory&lt;br /&gt;
** legal status of BSD kernel became an issue because of lawsuit&lt;br /&gt;
** GNU started Hurd&lt;br /&gt;
** Linus Torvalds writes Linux kernel&lt;br /&gt;
** uses GNU license&lt;br /&gt;
** allowed everyone to make contributions&lt;br /&gt;
* Eventually BSD legal stuff got figured out&lt;br /&gt;
** 386BSD&lt;br /&gt;
** FreeBSD&lt;br /&gt;
** NetBSD&lt;br /&gt;
*** OpenBSD&lt;br /&gt;
* Anil&#039;s opinion&lt;br /&gt;
* Linux has the best driver support of any OS including Windows&lt;br /&gt;
&lt;br /&gt;
== Back to Init ==&lt;br /&gt;
&lt;br /&gt;
* Why do we care?&lt;br /&gt;
* Unix is a culture&lt;br /&gt;
* the culture shows up all over, like in /etc, /etc/init.d&lt;br /&gt;
* Now there are 3 major replacements for system V init scripts&lt;br /&gt;
* system V init scripts are just shell scripts run sequentially&lt;br /&gt;
* it&#039;s desirable to run the initialization in parallel&lt;br /&gt;
** oh noes, race conditions&lt;br /&gt;
** init scripts have dependencies!!&lt;br /&gt;
* init scripts were ordered by convention&lt;br /&gt;
** had to figure out all the dependencies&lt;br /&gt;
** still not completely figured out&lt;br /&gt;
* everything on linux is an open source project&lt;br /&gt;
* look around for a good project to document&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
{{note|vmlinux}}: https://en.wikipedia.org/wiki/Vmlinux&lt;/div&gt;</summary>
		<author><name>Spenner2</name></author>
	</entry>
</feed>