1. same computer
  2. send must before receive: send(m)->cv(m)


if a and b happened on different machine, a||b, which means you can’t define which happen first

that’s why lamport’s clock is partial order

  1. local event    ti=ti+1     increment using for local event is 1
  2. sender include t in the msr

rcv: max(tj,ti)+1



# all kinds of command and special characters

In computing, a shebang (also called a sha-bang)——-   #!

#!/bin/sed -f
#!/bin/awk -f

Each of the above script header lines calls a different command interpreter, be it /bin/sh, the default shell (bash in a Linux system) or otherwise.

Invoking the script

chmod 555 scriptname (gives everyone read/execute permission) [2]

chmod +rx scriptname (gives everyone read/execute permission)

chmod u+rx scriptname (gives only the script owner read/execute permission)

Having made the script executable, you may now test it by ./scriptname. [3] If it begins with a “sha-bang” line, invoking the script calls the correct command interpreter to run it.

As a final step, after testing and debugging, you would likely want to move it to /usr/local/bin (as root, of course), to make the script available to yourself and all other users as a systemwide executable. The script could then be invoked by simply typing scriptname [ENTER] from the command-line.

Chapter 3. Special Characters

Comments. Lines beginning with a # (with the exception of #!) are comments and will not be executed.

A command may not follow a comment on the same line. There is no method of terminating the comment, in order for “live code” to begin on the same line. Use a new line for the next command.

Of course, a quoted or an escaped # in an echo statement does not begin a comment.

Command separator [semicolon]. Permits putting two or more commands on the same line.

echo hello; echo there

if [ -x "$filename" ]; then    #  Note the space after the semicolon.
#+                   ^^
  echo "File $filename exists."; cp $filename $filename.bak
else   #                       ^^
  echo "File $filename not found."; touch $filename
fi; echo "File test complete."

Terminator in a case option [double semicolon].

case "$variable" in
  abc)  echo "\$variable = abc" ;;
  xyz)  echo "\$variable = xyz" ;;

;;&, ;&

Terminators in a case option (version 4+ of Bash).

When considering directory names, a single dot represents the current working directory, and two dots denote the parent directory.

bash$ pwd

bash$ cd .
bash$ pwd

bash$ cd ..
bash$ pwd
	        echo -n

The dot often appears as the destination (directory) of a file movement command, in this context meaning current directory.

bash$ cp /home/bozo/current_work/junk/* .

Copy all the “junk” files to $PWD.


escape [backslash]. A quoting mechanism for single characters.

\X escapes the character X. This has the effect of “quoting” X, equivalent to ‘X’. The \ may be used to quote and , so they are expressed literally.

See Chapter 5 for an in-depth explanation of escaped characters.


Filename path separator [forward slash]. Separates the components of a filename (as in /home/bozo/projects/Makefile).

This is also the division arithmetic operator.


escape [backslash]. A quoting mechanism for single characters.


command substitution. The `command` construct makes available the output of command for assignment to a variable. This is also known as backquotes or backticks.


null command [colon]. This is the shell equivalent of a “NOP” (no op, a do-nothing operation). It may be considered a synonym for the shell builtin true. The : command is itself a Bashbuiltin, and its exit status is true (0).

ps -aux|grep mouse|awk ‘{print $2}’

ps -aux 列出所有process的信息,grep抓住,awk 只列出第二列的内容

man command



Variable substitution (contents of a variable).


echo $var1     # 5
echo $var2     # 23skidoo

A $ prefixing a variable name indicates the value the variable holds.

Example 4-3. Variable Assignment, plain and fancy


a=23              # Simple case
echo $a
echo $b

# Now, getting a little bit fancier (command substitution).

a=`echo Hello!`   # Assigns result of 'echo' command to 'a' ...
echo $a
#  Note that including an exclamation mark (!) within a
#+ command substitution construct will not work from the command-line,
#+ since this triggers the Bash "history mechanism."
#  Inside a script, however, the history functions are disabled by default.

a=`ls -l`         # Assigns result of 'ls -l' command to 'a'
echo $a           # Unquoted, however, it removes tabs and newlines.
echo "$a"         # The quoted variable preserves whitespace.
                  # (See the chapter on "Quoting.")

exit 0

4.3. Bash Variables Are Untyped

Unlike many other programming languages, Bash does not segregate its variables by “type.” Essentially, Bash variables are character strings, but, depending on context, Bash permits arithmetic operations and comparisons on variables. The determining factor is whether the value of a variable contains only digits.

find the file/number of line containing “matching_string”

sudo grep -rnw ‘path’ -e “matching_string”

no line folding

In less, it’s called line folding rather than line wrapping.  To set it not to fold, use the -S option:

-S, --chop-long-lines

Causes lines longer than the screen width to be chopped rather than folded. That is, the portion of a long line that does not fit in the screen width is not shown. The default is to fold long lines; that is, display the remainder on the next line.


Alternatively, as mentioned in the below comment, if you already opened the file, you can toggle the mode by typing -S (and then Enter for some implementations).



There are many different versions of UNIX, although they share common similarities. The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X.

The UNIX operating system

The UNIX operating system is made up of three parts; the kernel, the shell and the programs.

The kernel

The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.

As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

The shell

The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems).

The adept user can customise his/her own shell, and users can use different shells on the same machine. Staff and students in the school have the tcsh shell by default.

The tcsh shell has certain features to help the user inputting commands.

Filename Completion – By typing part of the name of a command, filename or directory and pressing the [Tab] key, the tcsh shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed, it will beep, prompting you to type a few more letters before pressing the tab key again.

History – The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands.

Files and processes

Everything in UNIX is either a file or a process.

A process is an executing program identified by a unique PID (process identifier).

A file is a collection of data. They are created by users using text editors, running compilers etc.

Examples of files:

  • a document (report, essay etc.)
  • the text of a program written in some high-level programming language
  • instructions comprehensible directly to the machine and incomprehensible to a casual user, for example, a collection of binary digits (an executable or binary file);
  • a directory, containing information about its contents, which may be a mixture of other directories (subdirectories) and ordinary files.


pwd (print working directory)

Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, type cd to get back to your home-directory and then type

% pwd

The full pathname will look something like this –



% ls unixstuff/backups


~ (your home directory)

Home directories can also be referred to by the tilde ~ character. It can be used to specify paths starting at your home directory. So typing

% ls ~/unixstuff

will list the contents of your unixstuff directory, no matter where you currently are in the file system.

What do you think

% ls ~

would list?

What do you think

% ls ~/..


Command Meaning
ls list files and directories
ls -a list all files and directories
mkdir make a directory
cd directory change to named directory
cd change to home-directory
cd ~ change to home-directory
cd .. change to parent directory
pwd display the path of the current directory


cp location/file1  location/file2

with the file type

mv file1 file2

To move a file from one place to another, use the mv command. This has the effect of moving rather than copying the file, so you end up with only one file rather than two.

It can also be used to rename a file, by moving the file to the same directory, but giving it a different name.


reference reading: Survey on caching approaches in Information Centric Networking //2015


Determining what part of the content is to be cached? When is the most appropriate time for caching?
How would the object be cached (placed and replaced) and also what path would the object be cached?
Thus, this paper span through some selected ICN architectures and projects to investigate and suggest
forms of caching in minimizing the total bandwidth consumption, enhanced Delivery of Service (DoS),
reduced upwards and downward streaming.

The caching influencing factors can further be elabo-rated as:

(a) Frequency – in number terms, how many requests are posted or how frequent is an object requested for?
(b) Recency – the time an object or content was referred to or demanded for
(c) Size – the size of a content
(d) Cost of retrieval – the cost incurred to retrieve the content or object
(e) Time of update – a modification in the cache
(f) Replacement – the best time a content becomes less relevant

reference reading: Survey on caching approaches in Information Centric Networking //2015

paper writing


1st  title abstract intro headings conclusion refs

2nd section figure

3st detail

an app named myline?


 put the most info at first of paragraph, for example the result including percent data


  1. motivation: broadly what is problem area why important
  2. narrow down what si problem you specifically consider 
  3. in the paper,…..most crucial para, tell your elevator pitch
  4. how different /better /relate to other work
  5. structure 

only put topic sentences related information into a single para

figs lists are better than text 

remove words para unnecessary 

less is more 

if you delete something and nothing changed , delete it 

clearly state your assumption what your work build on

state experiment condition 


the elements of style 

writing for computer science,

writing paper while doing research helps you find which part is unnecessary 

bullet point list of contribution in the intro on first page to help them to fill the review forms especially in the strengths part



Keywords: Enter key words or phrases in alphabetical order, separated by commas.

paper writing

erase os with ubuntu

I went through with almost the same thing with

after erasing os with ubuntu, a blinking question mark came out during the starting up.

thanks to the author replying email, I found this

but still, using the internet recovery, I can finally open with a os-like desktop with


until I can’t find any disk to install OS

then searching online again , found this


according to this:

  1. Back up drive on time machine.
  2. Restart, rebooting on Lion install disk.
  3. Go to Disk Utility.
  4. Erase Partition.
  5. Erase HD.
  6. Re-erase partition again, this time giving it a name.
  7. Click on HD.
  8. Verify HD to confirm EFI error message no longer appears.
  9. Go back to install screen.
  10. Choose restore from back up.

finally, there is no “efi error” happening.

Yet still, no disk is found.

At last, after clicking “mount” button, it’s OK.

erase os with ubuntu