$ dd if=/dev/zero of=new_image bs=1 count=new_size_of_ext3_in_bytes
$ dd if=old_image of=new_image conv=notrunc #copy the old image bytes to
the new image (without overwritting the new file)
$ losetup -o 32256 /dev/loop0 new_image # /root doesn't actually live
at front of image for HVM
$ fsck -f /dev/loop0 #check the new image for errors
$ echo "new_image_bytes / 8225280" | bc # this is number of cylinders
in new device
$ fdisk new_image
$ # go to the "extra" menu and type "c" and type the new number of cylinders
$ # go back to main menu
$ # delete primary partition (yes, delete it)
$ # add new primary partition w/ defaults # resize partition to size of
actual image file
$ # 'w' write out fdisk and exit
$ resize2fs /dev/loop0 20G #resize ext3 to whatever GB you want MINUS
a gigabyte ..... just to be on the safe side
$ losetup -d /dev/loop0 # get rid of the loop device
$ edit xen config and test new image (don't delete the old one!)
Wednesday, September 30, 2009
Monday, September 28, 2009
wget example
The following script
convert windows accept filenames
convert links to local link
convert cgi/jsp link to html file name
recursive download 3 levels
The following example want to download only html file from
one website and put it all the files in one certain directory
and convert link relationship to make it cross-referable.
convert windows accept filenames
convert links to local link
convert cgi/jsp link to html file name
recursive download 3 levels
wget --restrict-file-names=windows -E -r -p -l 3 -k -Ahtml -Ahtm -Ajpg -np
-nv -nd -nH http://www.fda.gov/Safety/Recalls/ArchiveRecalls/2007/default.htm
The following example want to download only html file from
one website and put it all the files in one certain directory
and convert link relationship to make it cross-referable.
#!/usr/bin/env bash
MONTH=("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec")
YEAR=("00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "90" "91" "92" "93" "94"
"95" "96" "97" "98" "99")
for mon in ${MONTH[*]}
do
for year in ${YEAR[*]}
do
x=$mon$year
mkdir ~/fay/$x
cd ~/fay/
wget -p -r -l 2 -k -nc -Ahtml -P$x -np -nv -nd -nH http://www.cpsc.
gov/cpscpub/prerel/prerel$x.html
done
done
echo "Wj Script done"
wget useful options
#usefule options
To download a single page and all its requisites (even if they exist
on separate websites), and make sure the lot displays properly
locally, this author likes to use a few options in addition to -p:
wget -E -H -k -K -p http:///
-np no parent
-H
--span-hosts
Enable spanning across hosts when doing recursive retrieving.
-A.c download .c file
-E add html extension to cgi/jsp script links
-K
--backup-converted
When converting a file, back up the original version with a .orig
suffix. Affects the behavior of -N.
-k
--convert-links The same as the above, but convert the links in the HTML
files to point to local files, so you can view the
documents off-line:
wget --convert-links -r http://www.gnu.org/ -o gnulog
---restrict-file-names=mode
windows doesn't accept certain file names like <>?
it can replace with certain chars like ? to #
-nc
--noclobber(no overwrite)
With -nc, download the same file will overwritten the old.
With -r -nc, download the same file will avoid overwriting, just use the original copy.
When running Wget without -N, -nc, -r, or p, downloading the same
file in the same directory will result in the original copy of file
being preserved and the second copy being named file.1.
-F
--force-html
When input is read from a file, force it to be treated as an HTML
file. This enables you to retrieve relative links from existing
HTML files on your local disk, by adding some url to
HTML, or using the --base command-line option.
-p
--page-requisites
This option causes Wget to download all the files that are
necessary to properly display a given HTML page. This includes
such things as inlined images, sounds, and referenced stylesheets.
-q
--quiet
Turn off Wget’s output.
-nv
--no-verbose
Turn off verbose without being completely quiet (use -q for that),
which means that error messages and basic information still get
printed.
wget -r -p -l 2 -np -nc -q http://www.cpsc.gov/cpscpub/prerel/prerel.html
Thursday, September 24, 2009
12球称重问题
脑筋问题挺好玩的。
有12个乒乓球,其中有一个重量不一样,但不知是轻是重,
请用天平称三次,把坏球找出来解法
----------------------------------
A1A2A3A4
B1B2B3B4
C1C2C3C4
A1-4 vs B1-4
思路关键就是要记住第一步的轻重对解决问题有指导性作用。
-----------------------------
还有8球问题,比较简单,分成332,先比较33就可以了。
这一题好像要知道坏球是重还是轻才行。
有12个乒乓球,其中有一个重量不一样,但不知是轻是重,
请用天平称三次,把坏球找出来解法
----------------------------------
B1B2B3B4
C1C2C3C4
A1-4 vs B1-4
- 如果A=B
那坏球在C堆里
C12 vs A12,如果相等,坏球在C34里,C3 vs A1 ....
如果不等,坏球在C12里,C1 vs A1 ...
不可能B1轻或者A2重,所以或者A1 轻,或者是B2B3重,
3.A1B1C1 > A2B2B3
either B1 重或者A2轻,
如果不等,坏球在C12里,C1 vs A1 ...
- 如果A<B(A>B同样处理,switch AB即可)
- A1B1C1 = A2B2B3
- A3B4 vs C1C2,
- if 相等,==》A4轻
- if < ==》A3 轻
- > ==》B4重
不可能B1轻或者A2重,所以或者A1 轻,或者是B2B3重,
- A1B2 vs C1C2
3.A1B1C1 > A2B2B3
either B1 重或者A2轻,
- B1 vs C1 ....
思路关键就是要记住第一步的轻重对解决问题有指导性作用。
-----------------------------
还有8球问题,比较简单,分成332,先比较33就可以了。
这一题好像要知道坏球是重还是轻才行。
Friday, September 11, 2009
Multikernel
Cache coherence become a problem with the increase of cores.
Using message passing instead of shared memory can solve the problem.
http://docs.google.com/present/view?id=dc3nqpnt_19hsg376hs
try to explain slide 21,
Broadcast vs Multicast:
TLB shootdown – the process of maintaining TLB consistency
by invalidating entries when pages are unmapped
– is one of the simplest operations in a multiprocessor
Multicast protocol, the master sends a URPC message to the first core of each processor,
fewer cache misses, and lower interconnect utilization,
particularly in the reverse direction from sink to
source. This occurs because sending packets as URPC
messages avoids any shared-memory other than the
URPC channel and packet payload; conversely, Linux
causes more cache-coherence traffic for shared-memory
synchronization.
Barrelfish also benefits by avoiding kernel crossings.
Using message passing instead of shared memory can solve the problem.
http://docs.google.com/present/view?id=dc3nqpnt_19hsg376hs
try to explain slide 21,
Broadcast vs Multicast:
TLB shootdown – the process of maintaining TLB consistency
by invalidating entries when pages are unmapped
– is one of the simplest operations in a multiprocessor
OS that requires global coordination. It is also
a short, but latency-critical, operation and so represents
a worst-case comparison for a multikernel.
a short, but latency-critical, operation and so represents
a worst-case comparison for a multikernel.
Broadcast performs badly due to the cache-coherence protocol used
by AMD64 processors. When the master updates the line, it is invalidated
in all other caches. Each slave core then pulls the new copy from the master’s
cache.
by AMD64 processors. When the master updates the line, it is invalidated
in all other caches. Each slave core then pulls the new copy from the master’s
cache.
which forwards it to the other three cores in the package.
Since they all share an L3 cache, this second message is much cheaper.
Since they all share an L3 cache, this second message is much cheaper.
IP Loopback
Table 4 shows that Barrelfish achieves higher throughput,fewer cache misses, and lower interconnect utilization,
particularly in the reverse direction from sink to
source. This occurs because sending packets as URPC
messages avoids any shared-memory other than the
URPC channel and packet payload; conversely, Linux
causes more cache-coherence traffic for shared-memory
synchronization.
Barrelfish also benefits by avoiding kernel crossings.
Wednesday, September 9, 2009
AICT new problem
I got into two problems right now with AICT
AICT Performance not as good as expected.
1.
S CPU1 T CPU2
I get the same performance(7300tran/s) with raise_softirq to T.
with aict I cannot get any performance improvement.
Since at CPU 2 side , T with C1 and C2 are competing for
CPU resources, with aict, T should get some kind of priority
hence smaller
2.
If I give up CPU at Target side right after target finish its I/O
shedule() doesn't take effect as I expected.
Problem: xenloop doesn't know when target should give up
cpu during xmit_packets().
Task: to find after schedule(), when could S get schduled
AICT Performance not as good as expected.
1.
S CPU1 T CPU2
I get the same performance(7300tran/s) with raise_softirq to T.
with aict I cannot get any performance improvement.
Since at CPU 2 side , T with C1 and C2 are competing for
CPU resources, with aict, T should get some kind of priority
hence smaller
2.
If I give up CPU at Target side right after target finish its I/O
shedule() doesn't take effect as I expected.
Problem: xenloop doesn't know when target should give up
cpu during xmit_packets().
Task: to find after schedule(), when could S get schduled
Subscribe to:
Posts (Atom)