java is faster then c
1) Heap alloc vs stack alloc
not a problem.
optimized?
2) New object in loop
not a problem.
reuse, optimized?
3) memory copy
not a problem
substring, byte array,
case by case, write good java source.
4) boundary check
java faster then c even with additional boundary check.
5) jdk size and startup time
wait java 9 with modular!
6) for loop in java vs memcmp, memcpy in c
not a problem
like a magic
编程的事
about neoe's programming
Tuesday, September 15, 2015
Saturday, January 17, 2015
How to Install Windows 7, the hack way
How to Install Windows 7, the hack way
========================================================
# The normal way
* use a usb-stick or CD-ROM installer
* install win7
* apply patches using windows updates
However, it costs hours, it's so clumsy that win7 do not apply patches in one time,
but download and install and reboot for serveral times.
Also some device drivers need to be installed manually.
# The easy way to dupliate a win7 installation.
* copy windows system partition into a new partition(on same disk or new disk).
* fix it (describe later)
* done
## details
* Scene 1 , the old disk is going to break, you need to move windows system into a new disk (maybe faster SSD)
* Scene 2 , you need a new windows 7 system for the new machine.
Step 1, copy the whole windows system partition(call it "System partition" later) to new target
```
I do it in linux,
cp -rp Win7Partition NewWin7Partition
```
Step 2, you need a bootable windows partition(call it "bootmgr" later)
* windows 7 use a 100MB partition as "bootmgr",
* the size can be larger or smaller
* actually it can be on the same partition as "System partition",
* "System partition" can be on an extended partition, but "Bootmgr" must be on the primary partition(because win7's foolish).
I'm talking about the traditional partition table, the are only 4 slot,
alloc it as 4 primary
or 3 primary + 1 extended (which contains infinity number of partition in theory but actually OS/bootloader will panic when you alloc too many)
* the partition "bootmgr" on, need tagged as "active", do it use fdisk (command a , toggle as bootable) or other tools like diskpart(on win7 installer disk)
* "bootmgr" need a bootloader program called bootmgr, which is a hidden file in root directory.
it can be created by `bootsect /nt60 all /force` (or maybe just copy the file)
it is safe to execute the command because it only affect dos/ntfs partition, your linux ext4 partition will stay safe, and
it is about to copy file, and will not write to MBR actually, unless you add "/mbr" option.
* bootmgr install need a BCD config, stored in BCD folder on the same partition of bootmgr file.
which can be installed by 'bcdboot x: /s y:', you can delete old BCD folder, so that the command can create a new "correct" one for you.
* the BCD can be viewed using `bcdedit /store file /enum /v` or be edited if necessary.
* BCD is same role as grub.cfg file in GRUB, it can load multipy windows on different locations, but it cannot load linux I guess.
## Conclusion
the keys are (1)A primary partition flagged as "active", (2) "bootmgr" single file on the primary partition,
(3) BCD directory with correct config on the same partition of "bootmgr"
In the end, you need a working bootloader, the true bootloader which installed physically on the the first sector of the disk.
which can be a windows one, or GRUB2(linux way), using "chainloader +1"
The process is:
* BIOS of motherboard load bootloader from first sector of disk
* bootloader loads itself then bootmgr
* bootmgr check active flag
* bootmgr load BCD config
* bootmgr load \windows\winload.exe(on which partition is according to UUID in BCD config file) to start windows.
If you get more troubles, try using the follow tools:
* bootsect
* bootrec
* bcdboot
* bcdedit
you may also need
* grub-install
* update-grub
If you also use Linux.
========================================================
# The normal way
* use a usb-stick or CD-ROM installer
* install win7
* apply patches using windows updates
However, it costs hours, it's so clumsy that win7 do not apply patches in one time,
but download and install and reboot for serveral times.
Also some device drivers need to be installed manually.
# The easy way to dupliate a win7 installation.
* copy windows system partition into a new partition(on same disk or new disk).
* fix it (describe later)
* done
## details
* Scene 1 , the old disk is going to break, you need to move windows system into a new disk (maybe faster SSD)
* Scene 2 , you need a new windows 7 system for the new machine.
Step 1, copy the whole windows system partition(call it "System partition" later) to new target
```
I do it in linux,
cp -rp Win7Partition NewWin7Partition
```
Step 2, you need a bootable windows partition(call it "bootmgr" later)
* windows 7 use a 100MB partition as "bootmgr",
* the size can be larger or smaller
* actually it can be on the same partition as "System partition",
* "System partition" can be on an extended partition, but "Bootmgr" must be on the primary partition(because win7's foolish).
I'm talking about the traditional partition table, the are only 4 slot,
alloc it as 4 primary
or 3 primary + 1 extended (which contains infinity number of partition in theory but actually OS/bootloader will panic when you alloc too many)
* the partition "bootmgr" on, need tagged as "active", do it use fdisk (command a , toggle as bootable) or other tools like diskpart(on win7 installer disk)
* "bootmgr" need a bootloader program called bootmgr, which is a hidden file in root directory.
it can be created by `bootsect /nt60 all /force` (or maybe just copy the file)
it is safe to execute the command because it only affect dos/ntfs partition, your linux ext4 partition will stay safe, and
it is about to copy file, and will not write to MBR actually, unless you add "/mbr" option.
* bootmgr install need a BCD config, stored in BCD folder on the same partition of bootmgr file.
which can be installed by 'bcdboot x: /s y:', you can delete old BCD folder, so that the command can create a new "correct" one for you.
* the BCD can be viewed using `bcdedit /store file /enum /v` or be edited if necessary.
* BCD is same role as grub.cfg file in GRUB, it can load multipy windows on different locations, but it cannot load linux I guess.
## Conclusion
the keys are (1)A primary partition flagged as "active", (2) "bootmgr" single file on the primary partition,
(3) BCD directory with correct config on the same partition of "bootmgr"
In the end, you need a working bootloader, the true bootloader which installed physically on the the first sector of the disk.
which can be a windows one, or GRUB2(linux way), using "chainloader +1"
The process is:
* BIOS of motherboard load bootloader from first sector of disk
* bootloader loads itself then bootmgr
* bootmgr check active flag
* bootmgr load BCD config
* bootmgr load \windows\winload.exe(on which partition is according to UUID in BCD config file) to start windows.
If you get more troubles, try using the follow tools:
* bootsect
* bootrec
* bcdboot
* bcdedit
you may also need
* grub-install
* update-grub
If you also use Linux.
Tuesday, September 16, 2014
Wednesday, September 10, 2014
Use single regular file as a filesystem
Why? it can be for portable,virtual,develop,audit,test,free,... nice things.
make a empty regular file
dd if=/dev/zero of=myExt4.img bs=4K count=1000
check if loop device available on your system:
ls /dev/loop*
if there is no loop device, need to load kernel modules, or even compile loop module:
(Linux 3.16.1)
make menuconfig
Device Drivers -> Block Devices -> Loopback device support
make -j4
make modules_install
modprobe loop
ls /dev/loop*
use loop device
losetup /dev/loop0 myExt4.img
mkfs.ext4 /dev/loop0
mount /dev/loop0 /mnt
echo "world">/mnt/hello
df
umount /mnt
done.
ADD:
use modprobe loop max_part=31
and fdisk /dev/loop0
mkfs /dev/loop0p1
to work on virtual multi-partition disk.
Load your OS kernel by Grub2 in a single file.
BIOS loads MBR in 512 bytes into memory 0000h:7c00h
But grub2 can load a whole file into memory 0000h:7c00h,(with a patch)
that means you can write your hobbist OS in one single file.
In this way, maybe other existing OS can be loaded easily.
in grub1 there is command "kernel=file" but I cannot find it in grub2.
grub2 has command linux16, but has other restriction about the format.
grub2 also provides command multiboot, but also spec condition should be met.
The method mentioned here, need only one condition is, the last 2 bytes of first 512 bytes
should be hex 55AA.
and the kernel file could be put in any existing filesystem can be recognized by grub2.
eg:
menuentry 'NEOS on vfat' {
insmod chain
insmod fat
set root='hd0,msdos4'
chainloader /neoskern
}
or:
menuentry 'NEOS on ext4' {
insmod part_msdos
insmod chain
insmod ext2
set root='hd0,msdos7'
chainloader /boot/neoskern
}
the patch info is here: http://savannah.gnu.org/bugs/?43184
Monday, September 1, 2014
8192cu on linux 3.16.1
It is said that 8192cu wifi driver is buggy.
I download driver from the maker site RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911
cannot compile because /proc API is changed since 3.10
I found patched versions on the net, they just make the /proc part dummy.
and I see interface wlan1(or wlan0 on yours). but no wireless extension using iwconfig. and Unsupported driver 'nl80211'. and ioctl[SIOCSIWMODE]: Operation not supported if use -DWext.
At last I found kernel modules for it is just not compiled(I used self-compiled kernel). And I tried default rtl8192cu module of kernel.
It worked.
I just don't know the reason.
But I learned to try kernel drivers.
I download driver from the maker site RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911
cannot compile because /proc API is changed since 3.10
I found patched versions on the net, they just make the /proc part dummy.
and I see interface wlan1(or wlan0 on yours). but no wireless extension using iwconfig. and Unsupported driver 'nl80211'. and ioctl[SIOCSIWMODE]: Operation not supported if use -DWext.
At last I found kernel modules for it is just not compiled(I used self-compiled kernel). And I tried default rtl8192cu module of kernel.
It worked.
I just don't know the reason.
But I learned to try kernel drivers.
Monday, August 11, 2014
install wifi usb driver ralink 7601 (FAILED)
This summary is not available. Please
click here to view the post.
Subscribe to:
Comments (Atom)