<?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=CindyYu</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=CindyYu"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php/Special:Contributions/CindyYu"/>
	<updated>2026-05-12T21:32:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_13&amp;diff=21154</id>
		<title>Operating Systems 2017F Lecture 13</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_13&amp;diff=21154"/>
		<updated>2017-10-27T02:24:41Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: /* Note */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on October 19, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec13-19Oct2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Files from the lecture [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec13/ are available].&lt;br /&gt;
&lt;br /&gt;
==Note==&lt;br /&gt;
&lt;br /&gt;
===Questions:===&lt;br /&gt;
Mutex and semaphore?&lt;br /&gt;
&lt;br /&gt;
Mutex is a binary semaphore, it is a semaphore that take a value that is zero or one, a classic semaphore can count.&lt;br /&gt;
&lt;br /&gt;
Mutex stands for ‘mutual exclusion’: I am exclusive access, no one else does.&lt;br /&gt;
&lt;br /&gt;
More general semaphore is used when you need to keep track of numbers.&lt;br /&gt;
&lt;br /&gt;
Most classic semaphore: read write semaphore. which will be seen in the kernel. The idea is multiple reader and only one writer.&lt;br /&gt;
&lt;br /&gt;
Most of the time we use mutex.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== dinner philosopher problem ===&lt;br /&gt;
&lt;br /&gt;
 Wiki page: https://en.wikipedia.org/wiki/Dining_philosophers_problem&lt;br /&gt;
&lt;br /&gt;
You have five philosophers sitting around the table, these philosophers will talk, and they will talk so much, they don’t really want to focus on eating. And for some reason there is not enough of forks at the table. There is one fork at every position between the plates. In order to eat anything, you need two forks.(Maybe better to think about using chopsticks instead of forks). There are five people there and only five forks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Senario 1: they all pick the left one at the same time, they all now have one fork.- can any of them eat? no, they suppose to use two forks to eat.&lt;br /&gt;
*Senario 2: Immediately put a fork down, wait for five seconds, and pick a fork. (have a delay, and pick it up) -they will never eat, because they always get one fork.&lt;br /&gt;
*Senario 3: randomize it? When they get one fork and couldn’t get the other one, they put it back down, wait a random amount of time and get the next one. -Yes this will work on average, except sometime randomly they will pick up a fork at the same time and starve to death. (unless you have a timeout)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This illustrate the concept of &#039;&#039;&#039;deadlock&#039;&#039;&#039;: you get to the point where the computation cannot proceed any further. Because the concurrence processes cannot get all the resource. Some of them can access the resources and some of them do not have the resources, so everyone stuck. &lt;br /&gt;
&lt;br /&gt;
 Wiki page: https://en.wikipedia.org/wiki/Deadlock&lt;br /&gt;
&lt;br /&gt;
When your computer logs up, a lot of time it is because of the deadlock. Something get locked and never get unlocked at the driver.&lt;br /&gt;
&lt;br /&gt;
One way to avoid deadlock: if you have enough resources you never have to share, deadlock never happen.&lt;br /&gt;
If you have shared resources, you can’t have deadlock.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the midterm we will do more kernel hacking.&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_13&amp;diff=21153</id>
		<title>Operating Systems 2017F Lecture 13</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_13&amp;diff=21153"/>
		<updated>2017-10-27T01:38:15Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on October 19, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec13-19Oct2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Files from the lecture [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec13/ are available].&lt;br /&gt;
&lt;br /&gt;
==Note==&lt;br /&gt;
&lt;br /&gt;
===Questions:===&lt;br /&gt;
Mutex and semaphore?&lt;br /&gt;
&lt;br /&gt;
Mutex is a binary semaphore, it is a semaphore that take a value that is zero or one, a classic semaphore can count.&lt;br /&gt;
&lt;br /&gt;
Mutex stands for ‘mutual exclusion’: I am exclusive access, no one else does.&lt;br /&gt;
&lt;br /&gt;
More general semaphore is used when you need to keep track of numbers.&lt;br /&gt;
&lt;br /&gt;
Most classic semaphore: read write semaphore. which will be seen in the kernel. The idea is multiple reader and only one writer.&lt;br /&gt;
&lt;br /&gt;
Most of the time we use mutex.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== dinner philosopher problem ===&lt;br /&gt;
&lt;br /&gt;
 Wiki page: https://en.wikipedia.org/wiki/Dining_philosophers_problem&lt;br /&gt;
&lt;br /&gt;
You have five philosophers sitting around the table, these philosophers will talk, and they will talk so much, they don’t really want to focus on eating. And for some reason there is not enough of forks at the table. There is one fork at every position between the plates. In order to eat anything, you need two forks.(Maybe better to think about using chopsticks instead of forks). There are five people there and only five forks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Senario 1: they all pick the left one at the same time, they all now have one fork.- can any of them eat? no, they suppose to use two forks to eat.&lt;br /&gt;
*Senario 2: Immediately put a fork down, wait for five seconds, and pick a fork. (have a delay, and pick it up) -they will never eat, because they always get one fork.&lt;br /&gt;
*Senario 3: randomize it? When they get one fork and couldn’t get the other one, they put it back down, wait a random amount of time and get the next one. -Yes this will work on average, except sometime randomly they will pick up a fork at the same time and starve to death. (unless you have a timeout)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This illustrate the concept of &#039;&#039;&#039;deadlock&#039;&#039;&#039;: you get to the point where the computation cannot proceed any further. Because the concurrence processes cannot get all the resource. Some of them can access the resources and some of them do not have the resources, so everyone stuck. &lt;br /&gt;
&lt;br /&gt;
 Wiki page: https://en.wikipedia.org/wiki/Deadlock&lt;br /&gt;
&lt;br /&gt;
When your computer logs up, a lot of time it is because of the deadlock. Something get locked and never get unlocked at the driver.&lt;br /&gt;
&lt;br /&gt;
One way to avoid deadlock: if you have enough resources you never have to share, deadlock never happen.&lt;br /&gt;
If you have shared resources, you can’t have deadlock.&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_10&amp;diff=21109</id>
		<title>Operating Systems 2017F Lecture 10</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_10&amp;diff=21109"/>
		<updated>2017-10-10T18:58:46Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_10&amp;diff=21108</id>
		<title>Operating Systems 2017F Lecture 10</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_10&amp;diff=21108"/>
		<updated>2017-10-10T18:58:38Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Assignmen is due Thursday&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
-more than one thing happening at the same time&lt;br /&gt;
&lt;br /&gt;
challenge with concurrency is keeping shared state consistent &lt;br /&gt;
-Files that are written to by multiple proceses&lt;br /&gt;
-Two or more processes communicating&lt;br /&gt;
-multiple threads within a process&lt;br /&gt;
&lt;br /&gt;
if you have two thing access one thing at the same time, which one reaches first?&lt;br /&gt;
&lt;br /&gt;
Concurrency leads to race conditions:&lt;br /&gt;
-order of interleaved actions affects output &lt;br /&gt;
-ex. did process A or B modify the file first?&lt;br /&gt;
&lt;br /&gt;
(generate random number, we will get different result, which we don’t want)&lt;br /&gt;
We want deterministic behavior from concurrent computations&lt;br /&gt;
-How to make sure they dont corporate each other?&lt;br /&gt;
-Need to have some sort of cordination&lt;br /&gt;
&lt;br /&gt;
To get consistent computation, we need to coordinate. (need to somehow interact with each other)&lt;br /&gt;
-but you can’t interact via regular variables (IMPORTANT)&lt;br /&gt;
&lt;br /&gt;
Regular variables are subject to the memory hierarchy&lt;br /&gt;
-variables are stored in registers, L1 chache, L2 chache, L3 chache, main memory&lt;br /&gt;
-can be deeper in some contexts&lt;br /&gt;
-so what if coordination variable is in L1 cache for one thread and in main memory for another?&lt;br /&gt;
-hardware maintains consistency… eventually&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How caching works&lt;br /&gt;
CPU caches are small pools of memory that store information the CPU is most likely to need next. Which information is loaded into cache depends on sophisticated algorithms and certain assumptions about programming code. The goal of the cache system is to ensure that the CPU has the next bit of data it will need already loaded into cache by the time it goes looking for it (also called a cache hit).&lt;br /&gt;
A cache miss, on the other hand, means the CPU has to go scampering off to find the data elsewhere. This is where the L2 cache comes into play — while it’s slower, it’s also much larger. Some processors use an inclusive cache design (meaning data stored in the L1 cache is also duplicated in the L2 cache) while others are exclusive (meaning the two caches never share data). If data can’t be found in the L2 cache, the CPU continues down the chain to L3 (typically still on-die), then L4 (if it exists) and main memory (DRAM).&lt;br /&gt;
&lt;br /&gt;
(refs: https://www.extremetech.com/extreme/188776-how-l1-and-l2-cpu-caches-work-and-why-theyre-an-essential-part-of-modern-chips)&lt;br /&gt;
&lt;br /&gt;
Variable: ranges of address, stored in multiple places. &lt;br /&gt;
L1: fastest, smallest, closest to the core&lt;br /&gt;
L2,&lt;br /&gt;
L3&lt;br /&gt;
Mechanisms for coordinating concurrent computatiosn must bypass the memory hierachy&lt;br /&gt;
instead use:&lt;br /&gt;
-filesystem locking primitives(kernel)&lt;br /&gt;
-special machine language instructions&lt;br /&gt;
 going to use abstraction to do conccurency&lt;br /&gt;
operating systems - kernels in particular - are highly concurrent&lt;br /&gt;
-make them painful to code&lt;br /&gt;
-have to always worry about having exclusive (or safe) access to data, have to make sure it is done properly&lt;br /&gt;
&lt;br /&gt;
abstruction, help us think about cuncurrency&lt;br /&gt;
Abstruction for managing concurrency:&lt;br /&gt;
-atomic variables guarantee strict ordering of operations (only one can be modified one time)&lt;br /&gt;
&lt;br /&gt;
Ex.&lt;br /&gt;
Variable x: ****** &amp;lt;-range of memory locations&lt;br /&gt;
&lt;br /&gt;
What does the cpu do to modify variable x?&lt;br /&gt;
-load x into register&lt;br /&gt;
-modify the register&lt;br /&gt;
-save the register to x&lt;br /&gt;
&lt;br /&gt;
Can i just modified directly in memory? Yes but it is much slower than using register. &lt;br /&gt;
register: very small relative to memory.&lt;br /&gt;
(to see more Register vs Memory : http://techdifferences.com/difference-between-register-and-memory.html)&lt;br /&gt;
&lt;br /&gt;
What if two cores try to modify variable x at the same time?&lt;br /&gt;
-both could have x in a register&lt;br /&gt;
&lt;br /&gt;
Let’s say x is 5&lt;br /&gt;
-core A increments by 1&lt;br /&gt;
-core B decrements by 1&lt;br /&gt;
&lt;br /&gt;
what’s x after both have run? Just go back to 5? &lt;br /&gt;
-coreA will increment 1, but coreB doesn’t register 5 yet, so will be 4&lt;br /&gt;
If B chages x but doesn’t see A’s change, you get 4.&lt;br /&gt;
If A changes x but doesn’t see B’s change… you get 6&lt;br /&gt;
-This is bad.&lt;br /&gt;
&lt;br /&gt;
What do I need?&lt;br /&gt;
I nee x to be atomic, ^^^ shouldn’t be possible.&lt;br /&gt;
-has to make sure only one core accesses x at a time&lt;br /&gt;
&lt;br /&gt;
only one core can load x in the memory and modify&lt;br /&gt;
cache have just different speed and differnet sizes.&lt;br /&gt;
(memory address, when you access the register? dont need to load data, it is in the register)&lt;br /&gt;
&lt;br /&gt;
Classic promitive&lt;br /&gt;
Atomic variables are typically used to build semaphores…&lt;br /&gt;
but what we really want is mutual exclusion&lt;br /&gt;
-only one threat/process/cpu can access the resource at a time&lt;br /&gt;
if A be there, B can’t be there. it is exclusive access.&lt;br /&gt;
want mutual exclusion for larger resources, e.g. data structures, devices&lt;br /&gt;
&lt;br /&gt;
higher-level languages directly support mutual exclusion, e.g. Java synchronized methods&lt;br /&gt;
(you have a object, it is synchronized, it only can happen one at a time.)&lt;br /&gt;
Semaphores are analogy  to a railraod control mechanism&lt;br /&gt;
-only one train on the track&lt;br /&gt;
&lt;br /&gt;
Change both direction on that one track, otherwise collision&lt;br /&gt;
They are using light signal.If that train is going south, the other one can’t go north…&lt;br /&gt;
If zero track, I can grab it. until I am done, no one can get it&lt;br /&gt;
semaphore is used to implement lock. its more primitive concept. &lt;br /&gt;
&lt;br /&gt;
when a train enters the shared track &lt;br /&gt;
-grab the semaphore (increment atomic variable)&lt;br /&gt;
-if not available, wait (check first to see if it is 0)&lt;br /&gt;
&lt;br /&gt;
when a train leaves the shared track&lt;br /&gt;
-release the semaphore(decrement atomic variable)&lt;br /&gt;
&lt;br /&gt;
lesson: don’t implement semaphores yourself, please!&lt;br /&gt;
&lt;br /&gt;
In the linux kernel&lt;br /&gt;
-locks semaphores of various types are associated with all kinds of data structures&lt;br /&gt;
e.g inodes&lt;br /&gt;
if you wanna access and modify inodes, it is a struct, you need to lock , otherwise if someone want to modify it, it would be dangerous.&lt;br /&gt;
Key question: when you can’t get the lock, what do you do?&lt;br /&gt;
-Sleep&lt;br /&gt;
 (tell the scheduler to wake you up when the lock is available)&lt;br /&gt;
Can the scheduler go to sleep? no. &lt;br /&gt;
what do they do try to grab something but can’t get it?&lt;br /&gt;
-deal with not getting resource&lt;br /&gt;
-spin (do a null loop) (spin in circle)&lt;br /&gt;
&lt;br /&gt;
If the wait time is short, spinning is the fastest thing you can do&lt;br /&gt;
-what happen when you sleep? &lt;br /&gt;
-can my sleep be woke up?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
where possible, everything should be exclusive, minimize sharing&lt;br /&gt;
&lt;br /&gt;
but in userspace…&lt;br /&gt;
-shared memory? NOooo&lt;br /&gt;
unless you use atomic variable, or something higher level&lt;br /&gt;
like semaphore&lt;br /&gt;
all the problem that kernel need to deal with it, you need to deal with it&lt;br /&gt;
-in general, shared memory is painful&lt;br /&gt;
-better way in general, use messages.&lt;br /&gt;
-series of meesges can be used to synchronize state&lt;br /&gt;
&lt;br /&gt;
3-way handshakes, e.g. opening a TCP connection(everytime you conncect a website...)&lt;br /&gt;
it have to sychrnoize state&lt;br /&gt;
-send SYN (synchronize) packet client-&amp;gt;server&lt;br /&gt;
-SYN ACK (acknowlege SYN) server-&amp;gt; client&lt;br /&gt;
-ACK(acknowlege) client-&amp;gt;server&lt;br /&gt;
why have to be 3-way?&lt;br /&gt;
first packet necessary to open the communicate, second one: the server tell the client i got your packet, all good.&lt;br /&gt;
what happen if SYN ACK get lost? &lt;br /&gt;
&lt;br /&gt;
there are message passing happening underneath many things.&lt;br /&gt;
&lt;br /&gt;
Where do i want to send message? I can send messages between processes, using...&lt;br /&gt;
-Signals!&lt;br /&gt;
-other ways too&lt;br /&gt;
(lots of different ways)&lt;br /&gt;
&lt;br /&gt;
classic pattern in concurrency&lt;br /&gt;
point: used to build compare solution&lt;br /&gt;
for example: sorting&lt;br /&gt;
&lt;br /&gt;
concurrency pattern: Producer/consumer&lt;br /&gt;
-two processes P and C&lt;br /&gt;
-P ‘makes’ things, C’consumes’ them&lt;br /&gt;
-want to coordinate P and C&lt;br /&gt;
-P shouldn’t produce too much (C gets too far behind)&lt;br /&gt;
-C shouldn’t waste tiem waiting for P&lt;br /&gt;
thinks you stuffing envelope&lt;br /&gt;
someone is opening, someone is sealing it, someone is stuffing inside the envelope&lt;br /&gt;
sometimes there would be someone is really slow stuffing, and someone is opening the envelope very fast. Or there are too much paper to make envelopes, which is kind of wastes.&lt;br /&gt;
&lt;br /&gt;
we want a signal say: hey hold on, when you get to some point,  just stop, let other people catchup, or switch job.&lt;br /&gt;
&lt;br /&gt;
-shared circular buffer for string output of P and input of C&lt;br /&gt;
-when buffer is empty, c should sleep?&lt;br /&gt;
-when the buffer is full, P should sleep?&lt;br /&gt;
(solution is suprising tricky)&lt;br /&gt;
what happen if the consumer is sleeping, the producer wake them up? don’t corrupt the buffer? how to you minimize the cost? Anil will talk about this next time.&lt;br /&gt;
&lt;br /&gt;
producer consumer in real life:&lt;br /&gt;
‘ls | more ‘&lt;br /&gt;
pipe is producer, consumer, one process producer, other is consumer, there is a buffer between this two things. kernel maintain this buffer. &lt;br /&gt;
How does it handle the coordination?&lt;br /&gt;
consumer read from the buffer (stdin, stdout), kernel knows it and implement it.&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21067</id>
		<title>Operating Systems 2017F Lecture 7</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21067"/>
		<updated>2017-10-03T20:20:59Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: /* Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 28, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec07-28Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
3000 Sep28&lt;br /&gt;
Next week: Anil is away from Sunday to Thursday morning. Review section.&lt;br /&gt;
&lt;br /&gt;
Topic today: File system&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What is a file?&#039;&#039;&#039;&lt;br /&gt;
It is a key - value pair.&lt;br /&gt;
&lt;br /&gt;
Key:  hierarchiacal filename (pathname)&lt;br /&gt;
&lt;br /&gt;
value: arbitrary number of bytes&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;In principle, you can use files to store very small values&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-most filesystems have a minimum file size of at least 1k, often 4K or more&lt;br /&gt;
&lt;br /&gt;
-one byte of data wastes a lot of space&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A set of files ‘stored’ together, sharing a common hierarchical root, is a filesystem.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Why quote ‘stored’ ? &lt;br /&gt;
&lt;br /&gt;
- Because there is no storage for virtual filesystems (such as /proc and /sys)&lt;br /&gt;
&lt;br /&gt;
when you first start a UNIX system, you start with the ‘root’ filesystem. (have nothing to do with root user.)&lt;br /&gt;
&lt;br /&gt;
-But other filesystems can be put on top by &amp;quot;mount&amp;quot;-ing them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘mount’&lt;br /&gt;
&lt;br /&gt;
it shows‘/dev/vda1 on / type ext4 (rw, relatetime,data=ordered) ‘ &lt;br /&gt;
&lt;br /&gt;
- /dev is root filesystem&lt;br /&gt;
&lt;br /&gt;
- / is the top of hierachy&lt;br /&gt;
&lt;br /&gt;
-‘rw’ means read write &lt;br /&gt;
&lt;br /&gt;
-/def/vda1 is a Special file, files in /dev are special files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Special files are actual files, it would be stored on disk, nowadays they are not.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘df .’ (df is for displaying the amount of available disk space for file systems on which the invoking user has appropriate read access.)&lt;br /&gt;
&lt;br /&gt;
-There is a filesystem called ‘udev’, which is a virtual file system with zero space used, since it is created automatically on run time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘who’ in another terminal&lt;br /&gt;
&lt;br /&gt;
-it display ‘soma tty7 2017-09-28 12:59 (:0)’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls /dev’&lt;br /&gt;
&lt;br /&gt;
-Instead of &#039;&#039;vda&#039;&#039;, it shows &#039;&#039;sda&#039;&#039;. The ‘v’ in &#039;&#039;vda&#039;&#039; stands for ‘virtual’. The ‘s’ in &#039;&#039;sda&#039;&#039; stands for SCSI (The Small Computer System Interface).&lt;br /&gt;
&lt;br /&gt;
-Any device you want to access on unix system has /dev&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls-a’ in /dev&lt;br /&gt;
&lt;br /&gt;
-Looking at the permissions (e.g ‘crw--rw----’), first letter for normal file is blank , directory is ‘d’, ‘c’ is for Character Devices, ‘b’ is for Block Devices&lt;br /&gt;
&lt;br /&gt;
-Character devices example: keyboard, mouse.&lt;br /&gt;
&lt;br /&gt;
-What makes b-disk different?caches.&lt;br /&gt;
&lt;br /&gt;
-Special files are either Character Devices or Block Devices,&lt;br /&gt;
&lt;br /&gt;
-Block divce is for block storage, to cache result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditional filesystems are stored in block devices&lt;br /&gt;
&lt;br /&gt;
-but a filesystem can be anything that provides a filesystem interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;file interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-open, read, write, seek, close&lt;br /&gt;
&lt;br /&gt;
-open directory, read/write directory, close directory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Block size issues:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-larger blocks, less overhead(fixed overhead for each block access)&lt;br /&gt;
&lt;br /&gt;
-smaller blocks, more efficient space usage(fewer files smaller than one block)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;filesystem interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-mount and unmount&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
filesystem blocksize is a multiple of disk blocksize&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do you structure a filesystem?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Inode:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First, you have to understand inodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.Run ‘cp lec07.txt test.txt’ &lt;br /&gt;
&lt;br /&gt;
-There is no different between those files&lt;br /&gt;
&lt;br /&gt;
2.Run ‘ln test.txt duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-There is difference between duplicate.txt and test.txt: A number for test.txt changed from ‘1’ to ‘2’. That number is inode count&lt;br /&gt;
&lt;br /&gt;
3. Run ‘ln duplicate.txt alsodup.txt’&lt;br /&gt;
&lt;br /&gt;
-Inode count number changed ‘2’ from ‘3’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ln&#039; stands for link&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4.Run ‘ln -s duplicate.txt another.txt’&lt;br /&gt;
&lt;br /&gt;
-There is no different between another.txt lec07.txt&lt;br /&gt;
&lt;br /&gt;
5.Run ‘ls -la has diffrence’&lt;br /&gt;
&lt;br /&gt;
-It shows another.txt -&amp;gt; duplicate.txt (symbolic link pointing one to the other&lt;br /&gt;
&lt;br /&gt;
6.Run ‘rm duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-The arrow is still pointing, but inode count number goes down. (From ‘3’ to ‘2’)&lt;br /&gt;
&lt;br /&gt;
7.Run ‘cat another.txt’&lt;br /&gt;
&lt;br /&gt;
	-It shows there is such file, because the file that pointing to is not exist&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-‘ln’ creates hard links to an item by default. &lt;br /&gt;
&lt;br /&gt;
-File name is a pointer to an inodes.&lt;br /&gt;
&lt;br /&gt;
-‘rm’ is not remove, just unlink, which reduces the link count for inode&lt;br /&gt;
&lt;br /&gt;
-When you clear storage, when inode inbound number go to 0, is not link to other file,system will remove it.&lt;br /&gt;
&lt;br /&gt;
-When the user open a file, referece count is incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A file sys doesn’t have to be a block device? It can store anywhere as long as you provide the api.&lt;br /&gt;
&lt;br /&gt;
A file system can be made in a file (the basic of virtual machine)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One other file api: mmap&lt;br /&gt;
&lt;br /&gt;
Inode store permision&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mmap, munmap: map or unmap files or devices into memory, this is the piece that unify the file sys with process memory.&lt;br /&gt;
&lt;br /&gt;
What ‘read’ does: read directly into RAM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘top’&lt;br /&gt;
&lt;br /&gt;
-There are ‘VIRT’, ‘RES’ and ‘SHR’&lt;br /&gt;
&lt;br /&gt;
 VIRT stands for the virtual size of a process&lt;br /&gt;
 RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming.&lt;br /&gt;
 SHR indicates how much of the VIRT size is actually sharable (memory or libraries).&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec07/ here].&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21066</id>
		<title>Operating Systems 2017F Lecture 7</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21066"/>
		<updated>2017-10-03T20:20:24Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: /* Video */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 28, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec07-28Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
3000 Sep28&lt;br /&gt;
Next week: Anil is away from Sunday to Thursday morning. Review section.&lt;br /&gt;
&lt;br /&gt;
Topic today: File system&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What is a file?&#039;&#039;&#039;&lt;br /&gt;
It is a key - value pair.&lt;br /&gt;
&lt;br /&gt;
Key:  hierarchiacal filename (pathname)&lt;br /&gt;
&lt;br /&gt;
value: arbitrary number of bytes&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;In principle, you can use files to store very small values&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-most filesystems have a minimum file size of at least 1k, often 4K or more&lt;br /&gt;
&lt;br /&gt;
-one byte of data wastes a lot of space&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A set of files ‘stored’ together, sharing a common hierarchical root, is a filesystem.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Why quote ‘stored’ ? &lt;br /&gt;
&lt;br /&gt;
- Because there is no storage for virtual filesystems (such as /proc and /sys)&lt;br /&gt;
&lt;br /&gt;
when you first start a UNIX system, you start with the ‘root’ filesystem. (have nothing to do with root user.)&lt;br /&gt;
&lt;br /&gt;
-But other filesystems can be put on top by &amp;quot;mount&amp;quot;-ing them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘mount’&lt;br /&gt;
&lt;br /&gt;
it shows‘/dev/vda1 on / type ext4 (rw, relatetime,data=ordered) ‘ &lt;br /&gt;
&lt;br /&gt;
- /dev is root filesystem&lt;br /&gt;
&lt;br /&gt;
- / is the top of hierachy&lt;br /&gt;
&lt;br /&gt;
-‘rw’ means read write &lt;br /&gt;
&lt;br /&gt;
-/def/vda1 is a Special file, files in /dev are special files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Special files are actual files, it would be stored on disk, nowadays they are not.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘df .’ (df is for displaying the amount of available disk space for file systems on which the invoking user has appropriate read access.)&lt;br /&gt;
&lt;br /&gt;
-There is a filesystem called ‘udev’, which is a virtual file system with zero space used, since it is created automatically on run time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘who’ in another terminal&lt;br /&gt;
&lt;br /&gt;
-it display ‘soma tty7 2017-09-28 12:59 (:0)’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls /dev’&lt;br /&gt;
&lt;br /&gt;
-Instead of &#039;&#039;vda&#039;&#039;, it shows &#039;&#039;sda&#039;&#039;. The ‘v’ in &#039;&#039;vda&#039;&#039; stands for ‘virtual’. The ‘s’ in &#039;&#039;sda&#039;&#039; stands for SCSI (The Small Computer System Interface).&lt;br /&gt;
&lt;br /&gt;
-Any device you want to access on unix system has /dev&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls-a’ in /dev&lt;br /&gt;
&lt;br /&gt;
-Looking at the permissions (e.g ‘crw--rw----’), first letter for normal file is blank , directory is ‘d’, ‘c’ is for Character Devices, ‘b’ is for Block Devices&lt;br /&gt;
&lt;br /&gt;
-Character devices example: keyboard, mouse.&lt;br /&gt;
&lt;br /&gt;
-What makes b-disk different?caches.&lt;br /&gt;
&lt;br /&gt;
-Special files are either Character Devices or Block Devices,&lt;br /&gt;
&lt;br /&gt;
-Block divce is for block storage, to cache result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditional filesystems are stored in block devices&lt;br /&gt;
&lt;br /&gt;
-but a filesystem can be anything that provides a filesystem interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;file interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-open, read, write, seek, close&lt;br /&gt;
&lt;br /&gt;
-open directory, read/write directory, close directory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Block size issues:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-larger blocks, less overhead(fixed overhead for each block access)&lt;br /&gt;
&lt;br /&gt;
-smaller blocks, more efficient space usage(fewer files smaller than one block)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;filesystem interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-mount and unmount&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
filesystem blocksize is a multiple of disk blocksize&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do you structure a filesystem?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Inode:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First, you have to understand inodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.Run ‘cp lec07.txt test.txt’ &lt;br /&gt;
&lt;br /&gt;
-There is no different between those files&lt;br /&gt;
&lt;br /&gt;
2.Run ‘ln test.txt duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-There is difference between duplicate.txt and test.txt: A number for test.txt changed from ‘1’ to ‘2’. That number is inode count&lt;br /&gt;
&lt;br /&gt;
3. Run ‘ln duplicate.txt alsodup.txt’&lt;br /&gt;
&lt;br /&gt;
-Inode count number changed ‘2’ from ‘3’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ln&#039; stands for link&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4.Run ‘ln -s duplicate.txt another.txt’&lt;br /&gt;
&lt;br /&gt;
-There is no different between another.txt lec07.txt&lt;br /&gt;
&lt;br /&gt;
5.Run ‘ls -la has diffrence’&lt;br /&gt;
&lt;br /&gt;
-It shows another.txt -&amp;gt; duplicate.txt (symbolic link pointing one to the other&lt;br /&gt;
&lt;br /&gt;
6.Run ‘rm duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-The arrow is still pointing, but inode count number goes down. (From ‘3’ to ‘2’)&lt;br /&gt;
&lt;br /&gt;
7.Run ‘cat another.txt’&lt;br /&gt;
&lt;br /&gt;
	-It shows there is such file, because the file that pointing to is not exist&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-‘ln’ creates hard links to an item by default. &lt;br /&gt;
&lt;br /&gt;
-File name is a pointer to an inodes.&lt;br /&gt;
&lt;br /&gt;
-‘rm’ is not remove, just unlink, which reduces the link count for inode&lt;br /&gt;
&lt;br /&gt;
-When you clear storage, when inode inbound number go to 0, is not link to other file,system will remove it.&lt;br /&gt;
&lt;br /&gt;
-When the user open a file, referece count is incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A file sys doesn’t have to be a block device? It can store anywhere as long as you provide the api.&lt;br /&gt;
&lt;br /&gt;
A file system can be made in a file (the basic of virtual machine)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One other file api: mmap&lt;br /&gt;
&lt;br /&gt;
Inode store permision&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mmap, munmap: map or unmap files or devices into memory, this is the piece that unify the file sys with process memory.&lt;br /&gt;
&lt;br /&gt;
What ‘read’ does: read directly into RAM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘top’&lt;br /&gt;
&lt;br /&gt;
-There are ‘VIRT’, ‘RES’ and ‘SHR’&lt;br /&gt;
&lt;br /&gt;
  VIRT stands for the virtual size of a process&lt;br /&gt;
  RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming.&lt;br /&gt;
  SHR indicates how much of the VIRT size is actually sharable (memory or libraries).&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec07/ here].&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21065</id>
		<title>Operating Systems 2017F Lecture 7</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Operating_Systems_2017F_Lecture_7&amp;diff=21065"/>
		<updated>2017-10-03T20:19:19Z</updated>

		<summary type="html">&lt;p&gt;CindyYu: /* Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on September 28, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec07-28Sep2017.mp4 is now available].&lt;br /&gt;
&lt;br /&gt;
3000 Sep28&lt;br /&gt;
Next week: Anil is away from Sunday to Thursday morning. Review section.&lt;br /&gt;
&lt;br /&gt;
Topic today: File system&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What is a file?&#039;&#039;&#039;&lt;br /&gt;
It is a key - value pair.&lt;br /&gt;
&lt;br /&gt;
Key:  hierarchiacal filename (pathname)&lt;br /&gt;
&lt;br /&gt;
value: arbitrary number of bytes&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;In principle, you can use files to store very small values&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-most filesystems have a minimum file size of at least 1k, often 4K or more&lt;br /&gt;
&lt;br /&gt;
-one byte of data wastes a lot of space&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A set of files ‘stored’ together, sharing a common hierarchical root, is a filesystem.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Why quote ‘stored’ ? &lt;br /&gt;
&lt;br /&gt;
- Because there is no storage for virtual filesystems (such as /proc and /sys)&lt;br /&gt;
&lt;br /&gt;
when you first start a UNIX system, you start with the ‘root’ filesystem. (have nothing to do with root user.)&lt;br /&gt;
&lt;br /&gt;
-But other filesystems can be put on top by &amp;quot;mount&amp;quot;-ing them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘mount’&lt;br /&gt;
&lt;br /&gt;
it shows‘/dev/vda1 on / type ext4 (rw, relatetime,data=ordered) ‘ &lt;br /&gt;
&lt;br /&gt;
- /dev is root filesystem&lt;br /&gt;
&lt;br /&gt;
- / is the top of hierachy&lt;br /&gt;
&lt;br /&gt;
-‘rw’ means read write &lt;br /&gt;
&lt;br /&gt;
-/def/vda1 is a Special file, files in /dev are special files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Special files are actual files, it would be stored on disk, nowadays they are not.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘df .’ (df is for displaying the amount of available disk space for file systems on which the invoking user has appropriate read access.)&lt;br /&gt;
&lt;br /&gt;
-There is a filesystem called ‘udev’, which is a virtual file system with zero space used, since it is created automatically on run time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘who’ in another terminal&lt;br /&gt;
&lt;br /&gt;
-it display ‘soma tty7 2017-09-28 12:59 (:0)’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls /dev’&lt;br /&gt;
&lt;br /&gt;
-Instead of &#039;&#039;vda&#039;&#039;, it shows &#039;&#039;sda&#039;&#039;. The ‘v’ in &#039;&#039;vda&#039;&#039; stands for ‘virtual’. The ‘s’ in &#039;&#039;sda&#039;&#039; stands for SCSI (The Small Computer System Interface).&lt;br /&gt;
&lt;br /&gt;
-Any device you want to access on unix system has /dev&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘ls-a’ in /dev&lt;br /&gt;
&lt;br /&gt;
-Looking at the permissions (e.g ‘crw--rw----’), first letter for normal file is blank , directory is ‘d’, ‘c’ is for Character Devices, ‘b’ is for Block Devices&lt;br /&gt;
&lt;br /&gt;
-Character devices example: keyboard, mouse.&lt;br /&gt;
&lt;br /&gt;
-What makes b-disk different?caches.&lt;br /&gt;
&lt;br /&gt;
-Special files are either Character Devices or Block Devices,&lt;br /&gt;
&lt;br /&gt;
-Block divce is for block storage, to cache result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traditional filesystems are stored in block devices&lt;br /&gt;
&lt;br /&gt;
-but a filesystem can be anything that provides a filesystem interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;file interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-open, read, write, seek, close&lt;br /&gt;
&lt;br /&gt;
-open directory, read/write directory, close directory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Block size issues:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-larger blocks, less overhead(fixed overhead for each block access)&lt;br /&gt;
&lt;br /&gt;
-smaller blocks, more efficient space usage(fewer files smaller than one block)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;filesystem interface basics:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
-mount and unmount&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
filesystem blocksize is a multiple of disk blocksize&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How do you structure a filesystem?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Inode:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First, you have to understand inodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CODE DEMONSTRATION:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1.Run ‘cp lec07.txt test.txt’ &lt;br /&gt;
&lt;br /&gt;
-There is no different between those files&lt;br /&gt;
&lt;br /&gt;
2.Run ‘ln test.txt duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-There is difference between duplicate.txt and test.txt: A number for test.txt changed from ‘1’ to ‘2’. That number is inode count&lt;br /&gt;
&lt;br /&gt;
3. Run ‘ln duplicate.txt alsodup.txt’&lt;br /&gt;
&lt;br /&gt;
-Inode count number changed ‘2’ from ‘3’&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ln&#039; stands for link&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4.Run ‘ln -s duplicate.txt another.txt’&lt;br /&gt;
&lt;br /&gt;
-There is no different between another.txt lec07.txt&lt;br /&gt;
&lt;br /&gt;
5.Run ‘ls -la has diffrence’&lt;br /&gt;
&lt;br /&gt;
-It shows another.txt -&amp;gt; duplicate.txt (symbolic link pointing one to the other&lt;br /&gt;
&lt;br /&gt;
6.Run ‘rm duplicate.txt’&lt;br /&gt;
&lt;br /&gt;
-The arrow is still pointing, but inode count number goes down. (From ‘3’ to ‘2’)&lt;br /&gt;
&lt;br /&gt;
7.Run ‘cat another.txt’&lt;br /&gt;
&lt;br /&gt;
	-It shows there is such file, because the file that pointing to is not exist&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-‘ln’ creates hard links to an item by default. &lt;br /&gt;
&lt;br /&gt;
-File name is a pointer to an inodes.&lt;br /&gt;
&lt;br /&gt;
-‘rm’ is not remove, just unlink, which reduces the link count for inode&lt;br /&gt;
&lt;br /&gt;
-When you clear storage, when inode inbound number go to 0, is not link to other file,system will remove it.&lt;br /&gt;
&lt;br /&gt;
-When the user open a file, referece count is incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A file sys doesn’t have to be a block device? It can store anywhere as long as you provide the api.&lt;br /&gt;
&lt;br /&gt;
A file system can be made in a file (the basic of virtual machine)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One other file api: mmap&lt;br /&gt;
&lt;br /&gt;
Inode store permision&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mmap, munmap: map or unmap files or devices into memory, this is the piece that unify the file sys with process memory.&lt;br /&gt;
&lt;br /&gt;
What ‘read’ does: read directly into RAM&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Run ‘top’&lt;br /&gt;
&lt;br /&gt;
-There are ‘VIRT’, ‘RES’ and ‘SHR’&lt;br /&gt;
&lt;br /&gt;
  VIRT stands for the virtual size of a process&lt;br /&gt;
  RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming.&lt;br /&gt;
  SHR indicates how much of the VIRT size is actually sharable (memory or libraries).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
Code and files from the lecture (captured as they were at the end) are available [http://homeostasis.scs.carleton.ca/~soma/os-2017f/code/lec07/ here].&lt;/div&gt;</summary>
		<author><name>CindyYu</name></author>
	</entry>
</feed>