2012年2月26日星期日

fedora16 software

Fedora16 shortcut bug:

workaround:

gconftool-2 --type=string --set "/desktop/gnome/applications/terminal/exec" "gnome-terminal"

solution:

sudo yum install libgnome-devel.i686 gnome-devel-docs.noarch

-----------------------------------------------------------------------------------------

User is not in the sudoers file

change file /etc/sudoers

su

xxxx

visudo

add command below at the end:

username ALL=(ALL)ALL

------------------------------------------------------------------------

yum install libreoffice-base libreoffice-core libreoffice-calc libreoffice-impress libreoffice-writer libreoffice-langpack-en

------------------------------------------------------------------

Flashplayer

Flash player

  64bit:

  su yum install wget cd /tmpwget http://download.macromedia.com/pub/labs/flashplayer10/flashplayer10_2_p3_64bit_linux_111710.tar.gztar xzvf flashplayer10_2_p3_64bit_linux_111710.tar.gzmv /tmp/libflashplayer.so /usr/lib64/mozilla/plugins/

  32bit:

  su

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

  rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

  yum update

  yum install flash-plugin

--------------------------------------

sudo yum install vlc

2012年2月25日星期六

X220 WIN7 & FEDORA 16

PRE:
A. prepare flash disk(at least 4G) to boot
and install fedora
B. need internet connection during fedora installation.
C. clear enough disk in windows
D. download
http://download.fedoraproject.org/pub/fedora/linux/releases/16/Fedora/i386/iso/Fedora-16-i386-DVD.iso
or
http://download.fedoraproject.org/pub/fedora/linux/releases/16/Fedora/x86_64/iso/Fedora-16-x86_64-DVD.iso
------------------------------------------------------------------
START:

1. download grubinst-1.1-bin-w32-2008-01-01 http://download.gna.org/grubutil/

2. download grub4dos-0.4.4 http://download.gna.org/grub4dos/

3. run grubinst_gui.exe(administrator mode), choose your flash disk, installation, u should see a window says "The MBR/BS has been successfully installed"

4. unzip grub4dos-0.4.4, copy
grldr and menu.lst to / of flash disk

5.copy
Fedora-16-Beta-i386-DVD.iso, initrd.img and vmlinux(these two are in iso, u need to extract them) to / of flash disk. So now flash disk have 5 files.

6. add commands below at the end of menu.lst:

title F16 setup

root (hd0,0)

kernel /vmlinuz root=/dev/hda1

initrd /initrd.img

----------------------------------------------------------------

ps: initrd.img might be initrd when extract from iso, do not care about that, do not add .iso.

-------------------------------------------------------------------

7. reboot, F12, choose to boot from flash disk

8.choose F16 setup

9. next, when you choose the installation storage type, I choose the last one, create blablabla, then you can cut your disk by yourself, make sure you backup your data first.

10. next next.....choose software development if you want to do some coding in fedora...

11. next.................

-------------------------------------------------------------------------------------------------------------

swap:2G

/:5G ext4

/home:30G ext4

/usr/locale:20G ext4

/tmp:1G ext4

/var:2G ext4

/boot:200M ext3

------------------------------------------------------------------------------------


Now you can go to a party or watch Big Bang Theory or White Collar(Moz is soooo cooool)

enjoy :)

2012年2月21日星期二

LOCK CV

OS161 PLATFORM

LOCK IMPLEMENTATION


CV(condition variable) is for multi thread use. wait-wakeup
eg: T1, T2, T1 need test_cond(bool type) is true to be run. And test_cond is controlled by T2. In this case, how to achieve this?

Method 1:

T1 is sleeping and wake up every 5ns (arbitrary, can be any time period) come to examine the value of test_cond,if it is false, keep sleep; otherwise, start to run.

Method2:

T1 call cond_wait and wait when test_cond is false, when the value of test_cond is changed, T2 will call cond_signal to wake up T1(which is sleep & busy waitng), tell T1: hi, the value of test_cond is changed. T1: got you, I am going to run.

We can see the scenario of the bathroom on a plane, T1(old lady)and T2(old man) are two people, T2 is in the bathroom, T1 want to use it...So T1 stand up again and again to see if the bathroom is available or not.(if there is no light to indicate that). That is a waste, it waste T1's energy , it influence the beautiful waitress to look after her, it waste other customers' energy to see her around.

So here we go,.we have a light outside the bathroom, when T2 is in the bathroom, the light is red, the lady can go back to the seat and sleep, when T2 is done with his work, he will turn the light to green, and the light will call old lady(advanced light), and old lady can use it now.

here is the chinese version.



here and here is the comparison between semaphore, mutex and cv





---------------------------------------------------


-------------------------------------


---------------------------------------------------




2012年2月19日星期日

socket select multiuser file sharing

select
fd_set
FD_SET
FD_ISSET
FD_CLR

fd_set is a fd pool which could allow us to use single thread to do stdin, listening, reading(receiveing) and writing. With stdin, we also can do writing(sending) and reading.
--------------------------------------------------------

2012年2月15日星期三

string

we can use strlen(string) > 0 to see if a string is empty or not.

strcmp
strncmp useful!!! to see whether the first n characters are the same.

strcpy
-----------------------------------------------------

how to get "download ..."
how to get the word between space

---------------------------------------------------------------
how to get a array return from a function, 3 array? Many data structures?

2012年2月13日星期一

warning

warning: backslash and newline separated by space
Solution: The backslash (\) character is used as the continuation character to continue #define statements and strings to the next line. GCC expects the backslash character to be the very last character on the line. This warning indicates that there is a space after the backslash. Delete the space and any other characters that come after the backslash.

2012年2月8日星期三

socket-----C

fprintf(out, "Hello %s\n", name);
printf
sprintf
--------------------------
perror
--------------------------------------------------
int i = 0;
while(i < 10)
{
printf(".");
sleep(1);
i ++;
}
--------------------------------------------
int i = 1;
while(i < 10)
{
fprintf(stderr,".");
sleep(1);
i ++;
}
----------------------------------------------
int i = 1;
while(i < 10)
{
printf(".");
fflush(stdout);
sleep(1);
i ++;
}
-------------------------------------------
1 gcc default path: /usr/include
2 gcc -I directory
3 do not search default

about the driver compilation, usually we do not need kernel to search for default path. enforce the kernel not to do that with a parameter
---------------------------------------------
how to get local ip in c on linux is here
-------------------------------------------------------------------
scp test.c xxxxxx@timberlake.cse.buffalo.edu:./

-----------------------------------------------------------

:133:174 co 299
----------------------------------------------

2012年2月6日星期一

MNC 2/6

HTTP & SMTP

PULL (HOST INIT TCP )

PUSH(SENDER SERVER PUSH INFO TO RECEIVER SERVER, RECEIVER SERVER INIT TCP)

ASC2 for SMTP, PERSISTENT

HTTP: OBJECT, EACH OBJ IN ITS OWN RESPONSE MSG

SMTP: EMAIL MESSAGE , MULTIPLE OBJ SENT IN MULTIPART MSG

--------------------------------------
WEB BASED EMAIL

POP3 IMAP
----------------

LOCAL DNS SERVER

13 ROOT SERVER

TLD DNS SERVER

AUTHORITATIVE DNS SERVER

------------------------------

www.google.com
google.com
just different alias which is mapped to the same IP

2012年2月5日星期日

OS&GIANTS

This semesor I take OS course under the instruction of Professor Geoffery. He is a really funny and nice guy. Because of him, I watched super bowl for the first time(no laugh pls...). And I found that it is reallllllly interesting!!!

I am glad to take this course althogh it would be very tough. But that's why I come here.

Hope I can be stronger two months later.

git

do not use Ctrl+z but Ctrl+x to exit when enter git commit help window

if you face this error:

fatal: Unable to create '/path/to/repo/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

this can solve the problem

rm .git/index.lock

----------------
git status
git diff
git reset HEAD <>
git checkout -- <>
git add <>
git commit
------------------
git tag -a "asst0-start" -m "ASST0 start"

vim ./gitignore

build
.depend
/defs.mk
kern/compile/
user/testbin/randcall/calls.c

-----------------------
When you clone a repository, Git automatically sets up the
remote repository you cloned from as linked to your clone.

git remote -v

Before you perform any merge it is best to have any changes in your
working directory committed.



2012年2月4日星期六

gdb tips

#gdbinit

(gdb) target remote unix:.sockets/gdb

#when gdb initiate, it will search and execute a file named .gdbinit under current directory

#if you are in gdb debugiing, use

source /.gdbinit
-----------------------------
r
n
s
c
b ; info b; d b n; disable b n; enable n
watch
bt
f n
l
i locals
set
p i
finish
c
q

-------------------------
(gdb) p i
$21 = 101
(gdb) p/a i
$22 = 0x65
(gdb) p/c i
$23 = 101 'e'
(gdb) p/f i
$24 = 1.41531145e-43
(gdb) p/x i
$25 = 0x65
(gdb) p/t i
$26 = 1100101