check it out!!

October 18, 2008 - Leave a Response

http://www.freemacbookpro.com/?referral=aazgry

10/01/08 Operating System Notes

October 4, 2008 - Leave a Response

Operating System Notes

Readers and Writers Problem:
Policy decisions:
Readers reading the resource. If a writer comes followed by a reader, whether we let the reader in first or the writer in first. If we let the readers in first, we probably have a situation of writers’ starvation. We do not preempt the resource.
Set the amount of readers that can get in front of the writers.
//————————————————-
typedef int semaphore;
semaphore protectCount = 1; //mutex
semaphore protectDB = 1; //mutex
int rc = 0;

void beforeWriting() {
P(protectDB);
}

void afterWriting() {
V(protectDB);
}

void beforeReading() {
P(portectCount);
if(++rc == 1) {
P(protectDB);
}
V(protectCount);
}

void afterReading() {
P(portectCount);
if(–rc == 0) {
V(protectDB);
}
V(protectCount);
}
//————————————————-

Lock the shared resources.
Do not access the value of semaphores.

Memory Management:

Binding:

  • If a program has a line: int x; When is the address of x decided.
  • At compile time
  • At load time
  • At run time

9/30/08 Unix Sys. Prog. Notes

October 1, 2008 - Leave a Response

09/30/08 Unix Sys. Prog. Notes

Set userid
effective userid changes

files and devices are similar because devices can be accessed by the entry in the file system

ls -l on devices mode looks like
crw–w—-
c – character special device
b – block special device

crw–w—- 1 jzhou01 tty 136, 17 2008-09-30 18:42 17
two numbers:
first: major device number
second: minor number

two persons can open a file at a time and a lseek to the end may be done before the other one writes something
First person: sheep
Second person: cat
Now: catep

flags fcntl (file_descriptor, F_GETFL)

O_APPEND bit

flags |= O_APPEND
fcntl (fd, f_SETFL, flags);

stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl
ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

input carriage return new line: interpret carriage return as a new line character.

fd = open (“somefile, O_WRONLY | O_APPEND);

pushd
popd

struct termios info;
int rv;
rv = tcgetattr (file_discriptor, &info);
tcsetattr
(file_descriptor, TCSANOW, &info);

It’s critical that the terminal buffers the input

Signals cannot be ignored:
Ctrl-Z: Suspend
kill (a mechanism to send a signal, not killing).
kill -KILL 12345

grep

September 30, 2008 - Leave a Response
  • grep regex files
    • regex is a regular expression
  • Options
    • -r, R: recurse down directories
    • -i: ignore case. Matches will be “case insensitive”
    • -v: inver the match
    • -c: only show the count of matching lines
    • -n: also show the line number of each match
    • -w: match pattern on “word” boundaries
      • grep -w cat files    # will not match "vacation"

ぼくがいる

September 24, 2008 - Leave a Response

ぼくがいる

明日になれば 涙が乾く

心も色づいて来る

笑顔が似合う あなたのために

いつでもこのぼくがいる

Read the rest of this entry »

Common Utilities

September 23, 2008 - Leave a Response
  • chmod - change the permissions on a file
  • cmp - compare sorted files
  • diff - difference between two files
  • df - disk space free
  • du - disk space used
  • head, tail – print the first or last lines of a file
  • make - run the commands in a “Makefile”
  • pushd, popd, dirs – keep a stack of “current” directories
  • sort - sort a file
  • tr - translate characters
  • uniq - remove duplicates
  • unmask - change / print the user file-creation mask
  • write - send a message to another user

find

September 23, 2008 - Leave a Response
  • Figure out where you put your files
    • find start options
  • find . -name pattern -print
  • Lists all files that match the pattern in the current directory or any sub-directories
  • The pattern should be in quotes to prevent the shell from using globbing in the current directory.
  • -print is a default action so it can be omitted if there is no other action.
  • find . -name "*.exe" -print -delete
  • Lists and deletes all files ending in .exe in the current directory and sub-directories.
  • Avoid using find on the root directory on a shared machine.

Unix System Programming Notes

September 22, 2008 - Leave a Response

The users account mapping in the unix system is stored in /etc/passwd

“grep jzhou01 /etc/passwd”

ctime(seconds) gives back a cstring with formatted time

EG Quiz for Lab4

September 22, 2008 - Leave a Response

Although I cannot state the questions, which I don’t know for now, I may be able to emphasize some details in Lab 4: Reverse Engineering. This lab is basically all about the gears and the gear trains. So, there we go, there are two types of gear trains: simple and compound gear trains. The simple gear train means that all the gears are in the same line, and compound gear trains are not. If there are three gears in a simple gear train with radii of R1, R2, R3, the gear ratio = (R2/R1)*(R3/R2), and the velocity ratio is (R1/R2)*(R2/R3), in other words, gear ratio = 1/ velocity ratio. Similar for compound gear train; the only difference is that in the compound gear train the radii to put into the formula have to be connected to each other.

Then there are 6 major gears:

  • Rack gear: change rotation to linear movement
  • Crown gear: change the direction of the movement perpendicularly
  • Spur gear: transmit the torque through the gear train
  • Worm gear: same purpose as the crown gear
  • Idler gear: does not change the velocity ratio
  • Pulley gear: transmit rotation from one point to another

And finally there are two formulas:

  1. F = m * a
  2. T = F * D

Physics 101. Easy stuff.

Tansfering from Blogger.com

September 22, 2008 - Leave a Response

WordPress just offers a lot more than Blogger.com, and I like the themes here.

Follow

Get every new post delivered to your Inbox.