Mic 的技术点滴:关于linux, wince 6.0...还有其他牢骚 mic's another world http://www.ootroo.com/zblog
  • HP笔记本分区错误

    2008-05-12 16:31:28

    公司买了HP KL535AV的新机子,我想装了linux上去却发现用pqmagic8.0分区出现问题。

    打电话给Hp的客服,他给我一个电话,打过去却发现是红旗linux的技术支持;他一个劲的问我要红旗的序列号,我当来没有了啊,我用的是fedora.

    所以只要在网上找文章,有个朋友说,需要先作一次chkdsk /f.我试了一下,果然有效! 特此记录,希望遇到同样问题的朋友可以参考。

     

     

  • page allocation failed

    2008-05-09 11:19:05

    查询了一些资料据说有以下的解决方法

    1. increase /proc/sys/vm/min_free_kbytes

    2. patch the mm patch

    <piggin@cyberone.com.au>
    [PATCH] mm: tune the page allocator thresholds

    without patch:
          pages_min   pages_low   pages_high
    dma        4          8          12
    normal   234        468         702
    high     128        256         384

    with patch:
          pages_min   pages_low   pages_high
    dma       17         21          25
    normal   939       1173        1408
    high     128        160         192

    without patch:
                                 | GFP_KERNEL        | GFP_ATOMIC
    allocate immediately         |   9 dma, 469 norm |  9 dma, 469 norm
    allocate after waking kswapd |   5 dma, 234 norm |  3 dma,  88 norm
    allocate after synch reclaim |   5 dma, 234 norm |  n/a

    with patch:
                                 | GFP_KERNEL         | GFP_ATOMIC
    allocate immediately         |  22 dma, 1174 norm | 22 dma, 1174 norm
    allocate after waking kswapd |  18 dma,  940 norm |  6 dma,  440 norm
    allocate after synch reclaim |  18 dma,  940 norm |  n/a

    So the buffer between GFP_KERNEL and GFP_ATOMIC allocations is:

    2.6.8      | 465 dma, 117 norm, 582 tot = 2328K
    2.6.10-rc  |   2 dma, 146 norm, 148 tot =  592K
    patch      |  12 dma, 500 norm, 512 tot = 2048K

    Which is getting pretty good.

    kswap starts at:
    2.6.8     477 dma, 496 norm, 973 total
    2.6.10-rc   8 dma, 468 norm, 476 total
    patched    17 dma, 939 norm, 956 total

    So in terms of total pages, that's looking similar to 2.6.8.

    Signed-off-by: Andrew Morton <akpm@osdl.org>
    Signed-off-by: Linus Torvalds torvalds@osdl.org

    怎么patch

    Yes, as far as I know, the -mm patchset is for the vanilla (www.kernel.org) kernel. To apply a patch to your kernel that you downloaded form www.kernel.org, first make sure that the patch you downloaded is for the kernel version you downloaded. Then extract the kernel source and put the patch in the root kernel source directory (such as /usr/src/linux-2.6.17.1/). Now decompress the patch and enter this command, as root, from that directory:

    Code:
    patch -p1 < [TheNameOfThePatchFile]
    Note the "<". Forgetting to put that in will probably mess up your patch file.

    Happy patching!

    --Dane


     

  • 收藏的好文<<When Linux Runs Out of Memory>>,待汉化

    2008-05-08 19:52:14

    When Linux Runs Out of Memory

    Perhaps you rarely face it, but once you do, you surely know what's wrong: lack of free memory, or Out of Memory (OOM). The results are typical: you can no longer allocate more memory and the kernel kills a task (usually the current running one). Heavy swapping usually accompanies this situation, so both screen and disk activity reflect this.

    At the bottom of this problem lie other questions: how much memory do you want to allocate? How much does the operating system (OS) allocate for you? The basic reason of OOM is simple: you've asked for more than the available virtual memory space. I say "virtual" because RAM isn't the only place counted as free memory; any swap areas apply.

    Exploring OOM

    To begin exploring OOM, first type and run this code snippet that allocates huge blocks of memory:

    #include <stdio.h>
    #include <stdlib.h>

    #define MEGABYTE 1024*1024

    int main(int argc, char *argv[])
    {
    void *myblock = NULL;
    int count = 0;

    while (1)
    {
    myblock = (void *) malloc(MEGABYTE);
    if (!myblock) break;
    printf("Currently allocating %d MB\n", ++count);
    }

    exit(0);
    }

    Compile the program, run it, and wait for a moment. Sooner or later it will go OOM. Now compile the next program, which allocates huge blocks and fills them with 1:

    #include <stdio.h>
    #include <stdlib.h>

    #define MEGABYTE 1024*1024

    int main(int argc, char *argv[])
    {
    void *myblock = NULL;
    int count = 0;

    while(1)
    {
    myblock = (void *) malloc(MEGABYTE);
    if (!myblock) break;
    memset(myblock,1, MEGABYTE);
    printf("Currently allocating %d MB\n",++count);
    }
    exit(0);

    }

    Notice the difference? Likely, program A allocates more memory blocks than program B does. It's also obvious that you will see the word "Killed" not too long after executing program B. Both programs end for the same reason: there is no more space available. More specifically, program A ends gracefully because of a failed malloc(). Program B ends because of the Linux kernel's so-called OOM killer.

    The first fact to observe is the amount of allocated blocks. Assume that you have 256MB of RAM and 888MB of swap (my current Linux settings). Program B ended at:

    Currently allocating 1081 MB

    On the other hand, program A ended at:

    Currently allocating 3056 MB

    Where did A get that extra 1975MB? Did I cheat? Of course not! If you look closer on both listings, you will find out that program B fills the allocated memory space with 1s, while A merely simply allocates without doing anything. This happens because Linux employs deferred page allocation. In other words, allocation doesn't actually happen until the last moment you really use it; for example, by writing data to the block. So, unless you touch the block, you can keep asking for more. The technical term for this is optimistic memory allocation.

    Checking /proc/<pid>/status on both programs will reveal the facts. Here's program A:

    $ cat /proc/<pid of program A>/status
    VmPeak: 3141876 kB
    VmSize: 3141876 kB
    VmLck: 0 kB
    VmHWM: 12556 kB
    VmRSS: 12556 kB
    VmData: 3140564 kB
    VmStk: 88 kB
    VmExe: 4 kB
    VmLib: 1204 kB
    VmPTE: 3072 kB

    Here's program B, shortly before the OOM killer struck:

    $ cat /proc/<pid of program B>/status 
    VmPeak: 1072512 kB
    VmSize: 1072512 kB
    VmLck: 0 kB
    VmHWM: 234636 kB
    VmRSS: 204692 kB
    VmData: 1071200 kB
    VmStk: 88 kB
    VmExe: 4 kB
    VmLib: 1204 kB
    VmPTE: 1064 kB

    VmRSS deserves further explanation. RSS stands for "Resident Set Size." It explains how many of the allocated blocks owned by the task currently reside in RAM. Also note that before B reaches OOM, swap usage is almost 100 percent (most of the 888MB), while A uses no swap at all. It's clear that malloc() itself did nothing more than just preserve a memory area, nothing else.

    Another question also arises. "Even without touching the pages, why is the allocation limit 3056MB?" This exposes an unseen limit. For every application in a 32-bit system, there is 4GB of address space available for usage. The Linux kernel usually splits the linear address to provide 0 to 3GB for user space and 3GB to 4GB for kernel space. User space is a room where a task can do anything it wants, while kernel space is solely for the kernel. If you try to cross this 3GB border, you will get a segmentation fault.

    (Side note: There is a kernel patch that gives the whole 4GB to userspace, at the cost of some context-switching.)

    The conclusion is that OOM happens for two technical reasons:

    1. No more pages are available in the VM.
    2. No more user address space is available.
    3. Both #1 and #2.

    Thus the strategies to prevent those circumstances are:

    1. Know how large the user address space is.
    2. Know how many pages are available.

    When you ask for a memory block, usually by using malloc(), you're asking the runtime C library whether a preallocated block is available. This block's size must at least equal the user request. If there is already a memory block available, malloc() will assign this block to the user and mark it as "used." Otherwise, malloc() must allocate more memory by extending the heap. All requested blocks go in an area called the heap. Do not confuse it with the stack, because the stack stores local variable and function return addresses. These two sections have different jobs.

    Where is the heap located in the address space? The process address map can tell you exactly where:

    $ cat /proc/self/maps
    0039d000-003b2000 r-xp 00000000 16:41 1080084 /lib/ld-2.3.3.so
    003b2000-003b3000 r-xp 00014000 16:41 1080084 /lib/ld-2.3.3.so
    003b3000-003b4000 rwxp 00015000 16:41 1080084 /lib/ld-2.3.3.so
    003b6000-004cb000 r-xp 00000000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cb000-004cd000 r-xp 00115000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cd000-004cf000 rwxp 00117000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cf000-004d1000 rwxp 004cf000 00:00 0
    08048000-0804c000 r-xp 00000000 16:41 130592 /bin/cat
    0804c000-0804d000 rwxp 00003000 16:41 130592 /bin/cat
    0804d000-0806e000 rwxp 0804d000 00:00 0 [heap]
    b7d95000-b7f95000 r-xp 00000000 16:41 2239455 /usr/lib/locale/locale-archive
    b7f95000-b7f96000 rwxp b7f95000 00:00 0
    b7fa9000-b7faa000 r-xp b7fa9000 00:00 0 [vdso]
    bfe96000-bfeab000 rw-p bfe96000 00:00 0 [stack]

    This is an actual address space layout shown for cat, but you may get different results. It is up to the Linux kernel and the runtime C library to arrange them. Notice that recent Linux kernel versions (2.6.x) kindly label the memory area, but don't completely rely on them.

    The heap is basically free space not already given for program mapping and stack; thus, it narrows down the available address space. It's not a full 3GB, but it's 3GB minus everything else that's mapped. The bigger your program's code segment is, the less space you have for heap. The more dynamic libraries you link into your program, the less space you get for the heap. This is important to remember.

    How does the map for program A look when it can't allocate more memory blocks? With a trivial change to pause the program (see loop.c and loop-calloc.c) just before it exits, the final map is:

    0009a000-0039d000 rwxp 0009a000 00:00 0 ---------> (allocated block)
    0039d000-003b2000 r-xp 00000000 16:41 1080084 /lib/ld-2.3.3.so
    003b2000-003b3000 r-xp 00014000 16:41 1080084 /lib/ld-2.3.3.so
    003b3000-003b4000 rwxp 00015000 16:41 1080084 /lib/ld-2.3.3.so
    003b6000-004cb000 r-xp 00000000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cb000-004cd000 r-xp 00115000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cd000-004cf000 rwxp 00117000 16:41 1080085 /lib/tls/libc-2.3.3.so
    004cf000-004d1000 rwxp 004cf000 00:00 0
    005ce000-08048000 rwxp 005ce000 00:00 0 ---------> (allocated block)
    08048000-08049000 r-xp 00000000 16:06 1267 /test-program/loop
    08049000-0804a000 rwxp 00000000 16:06 1267 /test-program/loop
    0806d000-b7f62000 rwxp 0806d000 00:00 0 ---------> (allocated block)
    b7f73000-b7f75000 rwxp b7f73000 00:00 0 ---------> (allocated block)
    b7f75000-b7f76000 r-xp b7f75000 00:00 0 [vdso]
    b7f76000-bf7ee000 rwxp b7f76000 00:00 0 ---------> (allocated block)
    bf80d000-bf822000 rw-p bf80d000 00:00 0 [stack]
    bf822000-bff29000 rwxp bf822000 00:00 0 ---------> (allocated block)

    Six Virtual Memory Areas, or VMAs, reflect the memory request. A VMA is a memory area that groups pages with the same access permission and/or the same backing file. VMAs can exist anywhere within user space, as long as that space is available.

    Now you might think, "Why six? Why not a single big VMA containing all blocks?" There are two reasons. First, it is often impossible to find such a big "hole" to coalesce the blocks into a single VMA. Second, the program does not ask to allocate that approximately 3GB block all at once, but piece by piece. Thus, the glibc allocator has complete freedom to arrange the memory however it wants.

    Why do I mention available pages? Memory allocation occurs in page-sized granularity. This is not a limit of the operating systems, but a feature of the Memory Management Unit (MMU) itself. Pages have various sizes, but the normal setting for x86 is 4K. You can discover the page size manually by using getpagesize() or sysconf() (with the _SC_PAGESIZE parameter) libc functions. The libc allocator manages each page: slicing them into smaller blocks, assigning them to processes, freeing them, and so on. For example, if your program uses 4097 bytes total, you need to use two pages, even though in reality the allocator gives you somewhere between 4105 to 4109 bytes.

    With 256MB of RAM and no swap, you have 65536 available pages. Is that right? Not really. What you don't see is that some memory areas are in use by kernel code and data, so they're unavailable for any other need. There is also a reserved part of memory for emergencies or high-priority needs. dmesg reveals these numbers for you:

    $ dmesg | grep -n kernel
    36:Memory: 255716k/262080k available (2083k kernel code, 5772k reserved,
    637k data, 172k init, 0k highmem)
    171:Freeing unused kernel memory: 172k freed

    init refers to kernel code and data that is only necessary for the initialization stage; thus the kernel frees it when it is no longer useful. That leaves 2083 + 5772 + 637 = 8492KB. Practically speaking, 2123 pages are gone from the user's point of view. If you enable more kernel features or insert more kernel modules, you'll use up more pages for exclusive kernel use, so be wise.

    Another kernel internal data structure is the page cache. The page cache buffers data recently read from block devices. The more caching work you do, the fewer free pages you actually have--but they are not really occupied, as the kernel will reclaim them when memory is tight.

    From the kernel and hardware points of view, these are the important things to remember:

    1. There is no guarantee that allocated memory area is physically contiguous; it's only virtually contiguous.

      This "illusion" comes from the way address translation works. In a protected mode environment, users always work with virtual addresses, while hardware works with physical addresses. The page directory and page tables translate between these two. For example, two blocks with starting virtual addresses 0 and 4096 could map to the physical addresses 1024 and 8192.

      This makes allocation easier, because in reality it is unlikely to always get continuous blocks, especially for large requests (megabytes or even gigabytes). The kernel will look everywhere for free pages to satisfy the request, not just adjacent free blocks. However, it will do a little more work to arrange page tables so that they appear virtually contiguous.

      There is a price. Because memory blocks might be non-contiguous, sometimes the L1 and L2 caches go underused. Virtually adjacent memory blocks may be spread across different physical cache lines; this means slowing down (sequential) memory access.

    2. Memory allocation takes two steps: first extending the length of memory area and then allocating pages when needed. This is demand paging. During VMA extension, the kernel merely checks whether the request overlaps existing VMA and if the range is still inside user space. By default, it omits the check whether actual allocation can occur.

      Thus it is not strange if your program asks for a 1GB block and gets it, even if in reality you have only 16MB of RAM and 64MB of swap. This "optimistic" style might not please everybody, because you might get the false hope of thinking that there are still free pages available. The Linux kernel offers tunable parameters to control this overcommit behavīor.

    3. There are two type of pages: anonymous pages and file-backed pages. A file-backed page originates from mmap()-ing a file in disk, whereas an anonymous page is the kind you get when doing malloc(). It has no relationship with any files at all. When the RAM becomes tight, the kernel swaps out anonymous pages to swap space and flushes file-backed pages to the file to give room for current requests. In other words, anonymous pages may consume swap area while file-backed pages don't. The only exception is for files mmap()-ed using the MAP_PRIVATE flag. In this case, file modification occurs in RAM only.

      This is where the understanding of swap as RAM extension comes from. Clearly, accessing the page requires bringing it back into RAM.



    Inside the Allocator

    The real work actually takes place inside the glibc memory allocator. The allocator hands out blocks to the application, carving them from the heap that comes (however infrequently) from the kernel.

    The allocator is the manager, while the kernel is the worker. With this in mind, it's easy to understand that maximum efficiency comes from a good allocator, not from the kernel.

    glibc uses an allocator named ptmalloc. Wolfram Gloger created it as a modified version of the original malloc library created by Doug Lea. The allocator manages the allocated blocks in terms of "chunks." Chunks represent the memory block you actually requested, but not its size. There is an extra header added inside this chunk besides the user data.

    The allocator uses two functions to get a chunk of memory from the kernel:

    • brk() sets the end of the process's data segment.
    • mmap() creates a new VMA and passes it to the allocator.

    Of course, malloc() uses these functions only if there are no more free chunks in the current pool.

    The decision on whether to use brk() or mmap() requires one simple check. If the request is equal or larger than M_MMAP_THRESHOLD, the allocator uses mmap(). If it is smaller, the allocator calls brk(). By default, M_MMAP_THRESHOLD is 128KB, but you may freely change it by using mallopt().

    In the OOM context, how ptmalloc frees memory blocks is interesting. Blocks allocated via mmap() get freed via an unmap() call, and thus become completely released. Freeing blocks allocated via brk() means marking them as free, but they remain under the allocator's control. It can reassign free chunks to satisfy another malloc() if the request's size is less than or equal to the chunk's size. The allocator can consolidate multiple free chunks, as long as they are adjacent. It may even split a free chunk into smaller chunks to satisfy smaller future requests.

    This implies that a free chunk may go abandoned if the allocator cannot fit future requests within it. Failure to coalesce free chunks may also trigger faster OOM. This is usually an indication of moderate to bad memory fragmentation.

    Recovery

    Once an OOM situation occurs, now what? The kernel will terminate one process for sure. Why kill? This is the only way to stop further memory requests. The kernel can not assume there is a sophisticated mechanism inside the process to stop further requests automatically, so it has no other choice but to kill it.

    How does the kernel know exactly which process to kill? The answer lies inside mm/oom_kill.c of the Linux source code. This C code represents the so-called OOM killer of the Linux kernel. The function badness() give a score to each existing processes. The one with highest score will be the victim. The criteria are:

    1. VM size. This is not the sum of all allocated pages, but the sum of the size of all VMAs owned by the process. The bigger the VM size, the higher the score.
    2. Related to #1, the VM size of the process's children are important too. The VM size is cumulative if a process has one or more children.
    3. Processes with task priorities smaller than zero (niced processes) get more points.
    4. Superuser processes are important, by assumption; thus they have their scores reduced.
    5. Process runtime. The longer it runs, the lower the score.
    6. Processes that perform direct hardware access are more immune.
    7. The swapper (pid 0) and init (pid 1) processes, as well as any kernel threads immune from the list of potential victims.

    The process with the biggest score "wins" the election and the OOM killer will kill it very soon.

    The heuristic isn't perfect, but usually it works well for most situations. Criteria #1 and #2 clearly show that it is the VMA size that matters, not the number of actual pages a process has. You might think that measuring VMA size will trigger a false alarm, but luckily it doesn't. The badness() call occurs inside the page allocation functions when there are few free pages left and page frame reclamation fails, so the VMA size closely matches the number of pages owned by the process.

    Why not just count the actual number of pages? That would require more time and require the use of locks, thus making the procedure too expensive to make a fast decision. Knowing that OOM killer isn't perfect, you must be ready for a wrong kill.

    The kernel uses the SIGTERM signal to inform the target process that it should stop.

    How to Reduce OOM Risk

    The simple rule to avoid OOM risk is actually simple: don't allocate beyond the machine's current free space. However, many factors come into play, so there are further refinements to the strategy.

    Reduce Fragmentation by Properly Ordering Allocation

    There is no need to use any sophisticated allocator. You can reduce fragmentation by properly ordering memory allocation and deallocation. As holes easily happen, employ the LIFO strategy: the last one you allocate is the first you need to free.

    For example, instead of doing:

            void *a;
    void *b;
    void *c;
    ............
    a = malloc(1024);
    b = malloc(5678);
    c = malloc(4096);

    ......................

    free(b);
    b = malloc(12345);

    It's better to do:

            a = malloc(1024);
    c = malloc(4096);
    b = malloc(5678);
    ......................

    free(b);
    b = malloc(12345);

    This way, there won't be any hole between the a and c chunks. You can also consider realloc() to resize any existingmalloc()-ed blocks.

    Two example programs (fragmented1.c and fragmented2.c) demonstrate the effect of allocation rearrangement. Reports at the end of both programs give the number of bytes allocated by the system (kernel and glibc allocator) and the number of bytes actually used. For example, on kernel 2.6.11.1, with glibc 2.3.3-27 and executing without giving an explicit parameter, fragmented1 wasted 319858832 bytes (about 305 MB) while fragmented2 wasted 2089200 bytes (about 2MB). That's 152 times smaller!

    You can do further experiments by passing various numbers as the program parameter. This parameter acts as the request size of the malloc() call.

    Tweak Kernel's Overcommit behavīor

    You can change the behavīor of the Linux kernel through the /proc filesystem, as documented in Documentation/vm/overcommit-accounting in the Linux kernel's source code. You have three choices when tuning kernel overcommit, expressed as numbers in /proc/sys/vm/overcommit_memory:

    • 0 means that the kernel will use predefined heuristics when deciding whether to allow such an overcommit. This is the default.
    • 1 always overcommits. Perhaps you now realize the danger of this mode.
    • 2 prevents overcommit from exceeding a certain watermark. The watermark is also tunable through /proc/sys/vm/overcommit_ratio. Within this mode, the total commit can not exceed the swap space(s) size + overcommit_ratio percent * RAM size. By default, the overcommit ratio is 50.

    The default mode usually work quite fine in most situation, but mode #2 offers better protection toward overcommit. On the other hand, mode #2 requires you to predict carefully how much space all running applications need. You certainly don't want to see your application unable to get more memory chunks just because the limit is too strict. However, mode #2 is a best way to avoid having a program killed suddenly.

    Suppose that you have 256MB of RAM and 256MB of swap and you want to limit overcommit at 384MB. That means 256 + 50 percent * 256MB, so put 50 on /proc/sys/vm/overcommit_ratio.

    Check for NULL Pointer after Memory Allocation and Audit for Memory Leak

    This is a simple rule, but it sometimes goes omitted. By checking for NULL, at least you know that the allocator could extend the memory area, although there is no obvious guarantee that it will allocate the needed pages later. Usually, you need to bail out or delay the allocation for a moment, depending on your scenarios. Together with overcommit tunables, you have a decent tool to anticipate OOM because malloc() will return NULL if it believes that it cannot acquire free pages later.

    Memory leak is also a source of unnecessary memory consumption. A leaked memory block is one that the application no longer tracks, but that the kernel will not reclaim because, from the kernel's point of view, the task still has it under control. Valgrind is a nice tool to find out such occurrences inside your code without the need to re-code.

    Always Consult Memory Allocation Statistics

    The Linux kernel provides /proc/meminfo as a way to find complete information about memory conditions. This /proc entry is also an information source for utilities such as top, free, and vmstat.

    What you need to check is the free and reclaimable memory. The word "free" needs no further explanation, but what does "reclaimable" mean? It refers to buffers and page caches--the disk cache. They are reclaimable because, when memory is tight, the Linux kernel can simply flush them out back to the disk. These are file-backed pages. I've lightly edited this example of memory statistics:

       $ cat /proc/meminfo
    MemTotal: 255944 kB
    MemFree: 3668 kB
    Buffers: 13640 kB
    Cached: 171788 kB
    SwapCached: 0 kB
    HighTotal: 0 kB
    HighFree: 0 kB
    LowTotal: 255944 kB
    LowFree: 3668 kB
    SwapTotal: 909676 kB
    SwapFree: 909676 kB

    Based on this above output, the free virtual memory is MemFree + Buffers + Cached + SwapFree = 1098772 kB.

    I failed to find any formalized C (glibc) function to find out free (including reclaimable) memory space. The closest I found is by using get_avphys_pages() or sysconf() (with the _SC_AVPHYS_PAGES parameter). They only report the amount of free memory, not the free + reclaimable amount.

    That means to get precise information, you must programmatically parse the /proc/meminfo and calculate it by yourself. If you're lazy, take the procps source package as a reference on how to do it. This package contains tools such as ps, top, and free. It is available under the GPL.

    Experiments with Alternative Memory Allocators

    Different allocators yield different ways to manage memory chunks and to shrink, expand, and create virtual memory areas. Hoard is one example. Emery Berger from the University of Massachusetts wrote it as a high performance memory allocator. Hoard seems to work best for multi-threaded applications; it introduces the concept of per-CPU heap.

    Use 64-bit Platforms

    Users who need larger user address spaces can consider using 64-bit platforms. The Linux kernel no longer uses the 3:1 VM split for these machines. In other words, user space becomes quite large. It can be a good match for machines with more than 4GB of RAM.

    This has no connection to extended addressing schemes, such as Intel's Physical Address Extension (PAE), which allows a 32-bit Intel processor to address up to 64GB of RAM. This addressing deals with physical address, while in the virtual address context, the user space itself is still 3GB (assuming the 3:1 VM split). This extra memory is reachable, but not all mappable into the address space. Unmappable portions of RAM are unusable.

    Consider Packed Types on Structures

    Packed attributes can help to squeeze the size of structs, enums, and unions. This is a way to save more bytes, especially for array of structs. Here is a declaration example:

    struct test
    {
    char a;
    long b;
    } __attribute__ ((packed));

    The con for this action is that it makes certain field(s) unaligned and thus it costs more CPU cycles to access the field. "Aligned" here means the variable's address is a multiple of its data type's natural size. The net result is that, depending on the data access frequency, the runtime may get relatively slower. However, take into account page alignment and cache coherence.

    Use ulimit() for User Processes

    With ulimit -v, you can limit the address space a process can allocate with mmap(). When you reach the limit, all mmap(), and hence malloc(), calls will return 0 and the kernel's OOM killer will never start. This is most useful in a multi-user environment where you cannot trust all of the users and want to avoid killing random processes.

    Acknowledgement

    The author gives credits to several people for their assistance and help: Peter Ziljtra, Wolfram Gloger, and Rene Hermant. Mr. Gloger also contributed the ulimit() technique.

    References

    1. "Dynamic Storage Allocation: A Survey and Critical Review," by Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles. Proceeding 1995 International Workshop of Memory Management.
    2. Hoard: A Scalable Memory Allocator for Multithreaded Applications, by Emery D. Berger, Kathryn S. McKinley, Robert D. Blumofe, and Paul R. Wilson
    3. "Once upon a free()" by Anonymous, Phrack Volume 0x0b, Issue 0x39, Phile #0x09 of 0x12.
    4. "Vudo: An Object Superstitiously Believed to Embody Magical Powers," by Michel "MaXX" Kaempf. Phrack Volume 0x0b, Issue 0x39, Phile #0x08 of 0x12.
    5. "Policy-Based Memory Allocation," by Andrei Alexandrescu and Emery Berger. C/C++ Users Journal.
    6. "Security of memory allocators for C and C++," by Yves Younan, Wouter Joosen, Frank Piessens, and Hans Van den Eynden. Report CW419, July 2005
    7. Lecture notes (CS360) about malloc(), by Jim Plank, Dept. of Computer Science, University of Tennessee.
    8. "Inside Memory Management: The Choices, Tradeoffs, and Implementations of Dynamic Allocation," by Jonathan Bartlett
    9. "The Malloc Maleficarum," by Phantasmal Phantasmagoria
    10. Understanding The Linux Kernel, 3rd edition, by Daniel P. Bovet and Marco Cesati. O'Reilly Media, Inc.
  • kmalloc, vmalloc分配的内存结构

    2008-05-08 13:47:50

    对于提供了MMU(存储管理器,辅助操作系统进行内存管理,提供虚实地址转换等硬件支持)的处理器而言,Linux提供了复杂的存储管理系统,使得进程所能访问的内存达到4GB。

      进程的4GB内存空间被人为的分为两个部分--用户空间与内核空间。用户空间地址分布从0到3GB(PAGE_OFFSET,在0x86中它等于0xC0000000),3GB到4GB为内核空间。

      内核空间中,从3G到vmalloc_start这段地址是物理内存映射区域(该区域中包含了内核镜像、物理页框表mem_map等等),比如我们使用的 VMware虚拟系统内存是160M,那么3G~3G+160M这片内存就应该映射物理内存。在物理内存映射区之后,就是vmalloc区域。对于 160M的系统而言,vmalloc_start位置应在3G+160M附近(在物理内存映射区与vmalloc_start期间还存在一个8M的gap 来防止跃界),vmalloc_end的位置接近4G(最后位置系统会保留一片128k大小的区域用于专用页面映射)

         kmalloc和get_free_page申请的内存位于物理内存映射区域,而且在物理上也是连续的,它们与真实的物理地址只有一个固定的偏移,因此存在较简单的转换关系,virt_to_phys()可以实现内核虚拟地址转化为物理地址:
        #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
        extern inline unsigned long virt_to_phys(volatile void * address)
        {
             return __pa(address);
        }
    上面转换过程是将虚拟地址减去3G(PAGE_OFFSET=0XC000000)。

    与之对应的函数为phys_to_virt(),将内核物理地址转化为虚拟地址:
        #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
        extern inline void * phys_to_virt(unsigned long address)
        {
             return __va(address);
        }
    virt_to_phys()和phys_to_virt()都定义在include\asm-i386\io.h中。

    而vmalloc申请的内存则位于vmalloc_start~vmalloc_end之间,与物理地址没有简单的转换关系,虽然在逻辑上它们也是连续的,但是在物理上它们不要求连续。

    我们用下面的程序来演示kmalloc、get_free_page和vmalloc的区别:
    #include <linux/module.h>
    #include <linux/slab.h>
    #include <linux/vmalloc.h>
    MODULE_LICENSE("GPL");
    unsigned char *pagemem;
    unsigned char *kmallocmem;
    unsigned char *vmallocmem;

    int __init mem_module_init(void)
    {
     //最好每次内存申请都检查申请是否成功
     //下面这段仅仅作为演示的代码没有检查
     pagemem = (unsigned char*)get_free_page(0);
     printk("<1>pagemem addr=%x", pagemem);

     kmallocmem = (unsigned char*)kmalloc(100, 0);
     printk("<1>kmallocmem addr=%x", kmallocmem);

     vmallocmem = (unsigned char*)vmalloc(1000000);
     printk("<1>vmallocmem addr=%x", vmallocmem);

     return 0;
    }

    void __exit mem_module_exit(void)
    {
     free_page(pagemem);
     kfree(kmallocmem);
     vfree(vmallocmem);
    }

    module_init(mem_module_init);
    module_exit(mem_module_exit);

      我们的系统上有160MB的内存空间,运行一次上述程序,发现pagemem的地址在0xc7997000(约3G+121M)、kmallocmem地址在0xc9bc1380(约3G+155M)、vmallocmem的地址在0xcabeb000(约3G+171M)处,符合前文所述的内存布局。

    来源: http://dev.yesky.com/412/2639912.shtml

  • linux学习网站

    2008-05-01 10:33:53

    http://www.linux-tutorial.info/index.php

    Welcome to the
    Linux Knowledge Base and Tutorial
    "The place where you learn Linux"

    Looking for an in-depth and easy-to-understand introduction to Linux? Then look no further!
    We don't just show you how to execute a handful of commands and use a few utilities. The Linux Tutorial goes beyond the basics, providing you with the knowledge necessary to get the most out of your Linux system.

    Jump right in by clicking here.

  • Want an in-depth introduction to Linux? Then check out hundreds of articles in the tutorial.
  • Need answers to specific questions? Then check out our forums.
  • Not sure what a particular term means? Then check out the glossary.
  • Want to make sure you learned everything? Then test yourself with more than 600 questions in our online quiz.

    For details on all of the features, check out the FAQ.

  • mobilelin创意大赛

    2008-04-30 17:11:47

    欢迎来到 YourMove,Moblin 开发人员的挑战竞技场。我们为您提供开发 Moblin 核心、基于 Linux 的应用程序所需的所有工具,以供娱乐或与 MID 设备通信。您现在进入的是一个神奇的世界,能够充分发挥您的创造力。您将保留知识产权而我们将帮助您获得市场领先地位。获胜者将获得丰厚的现金奖励、MID 设备以及免费参加世界任何地区的一个开源活动。请抓紧时间注册,竞赛将已经开始。我们开始吧!

    Moblin在MID软件系统中扮演三个关键角色

    1)    创建一个开发人员社区,关注创建和增强基于Linux的MID和其他设备所需的核心技术。最先创建Moblin时,这是该项目的首要目标。创建MID为目标的Linux操作系统版本的供应商将使用此核心技术。

    2)    创建一个开发人员社区,关注创建能给Moblin核心Linux堆栈增加价值或带来创新的新软件和服务。随着基于最新Intel® Centrino® Atom™处理技术的第一代MID的发布,Moblin项目的角色逐渐包含了这一关键功能。

    3)    定义一组标准和工具,使操作系统供应商(OSV)和ISV能够轻松确保跨多个供应商的Linux版本的二进制兼容性。
     
     

    http://moblincontest.csdn.net/

  • unbuntu在Nokia N810上的移植(转linuxdevices)

    2008-04-22 12:06:09

    看到这个新闻很高兴,因为我也一直期待unbuntu能够出arm版本。 这样一来,我们在手持设备上也能享受丰富的unbuntu软件了。

    稍后我会翻译一下


    A Nokia-sponsored project is porting Ubuntu Linux to the ARM architecture. The "Handheld Mojo" team has completed ARM builds of Feisty Fawn (dubbed "Frisky Firedrake") and Gutsy Gibbon ("Grumpy Griffin"), with Hardy Heron compilation starting soon.

    Spread the word:
    digg this story
    Mojo's Ubuntu port for ARM can be tested in QEMU, an open source emulator that supports various ARM architectures. Or, it can be run in a chrooted environment from an SD flash memory card installed on Nokia's Linux-based N8xx series Internet tablets. Since the ports are built for ARM Ltd.'s ARMv5EL and ARMv6EL-VFP architectures, they should also run on lots of other devices with ARM9 and ARM11 cores.

    With a few exceptions, most Ubuntu software compiles fine for ARM, according to Andrew Christian, the engineering fellow at Nokia who leads the effort. Notable exceptions are Java, Mono, G77 (a Fortran compiler), and the software that depends on them.

    Speaking at the Embedded Linux Conference in Mountain View this week, Christian showed an N800 tablet running the GIMP, an open source image processing package that he said worked well on the device.

    Christian told attendees that cross-compiling is much faster than native compilation. However, he said that most Debian (and by extension, Ubuntu) packages are not correctly set up for cross-build environments. For that reason, his team found it better to compile natively, because less human intervention is required.

    In setting up a native build environment, Mojo went to the extent of assembling its own single-board computer around an ARM-based Intel processor. Installed in 1U rackmount cases, and stacked up in a rack, the boards can collectively compile the 25,000 binaries comprising a full Ubuntu distribution (some packages build more than one object file) in about 10 days, Christian said. He commented that cooling fans installed in the cases were "probably overkill."

    To bootstrap a native ARM development toolchain, Christian used the ARM EABI port contributed to Debian in early 2007 by single-board computer vendor ADS. This saved considerable time, he said.

    Christian also said he thought Debian should change how it packages source code for ARM's several variations. Instead of treating each as a completely separate architecture, the project should use the Deb package format's directory structure to organize sub-architectures, and the architecture field in the format's meta-data to specify where the package ought to build, with "ARM-all" being one possible option.

    In an interview with LinuxDevices, Christian said that his team looked forward to creating more powerful native ARM build systems. In particular, he was encouraged to try commodity ARM-based NAS servers that could be modified to accept up to 2GB of RAM, according to reports from hobbyists around the Internet. The current Mojo boards top out at 256MB, and become memory-bound building large packages like KDE, he said.

    As an alternative to ARM-based machines, Mojo is also testing x86 servers with QEMU-ARM emulation software. QEMU is reportedly faster than real ARM hardware when run on newer x86-based PCs.

    Besides Christian, other key developers working on the port include Brian Avery, veteran of HP's iPaq Linux port, and George France, former maintainer of the Linux kernel for the Alpha architecture.
  • mizi介绍

    2008-04-16 09:52:48


    韩国的mizi是一家专业的linux开发公司,其产品从linux内核到应用,到开发平台,都显示着其专业的linux技术。

    尤其是他的prizm平台,非常的炫。现在市面上已经有手机(samsung的)装载了prizm.linux手机能做成这种效果,真的很让人吃惊

    公司也在用prizm,手头就有个装载prizm的家伙,非常酷,菜单切换的效果很炫,好像iphone,而且他的桌面非常有意思,用户自己可以拖拽桌面上的控件。

    ARCHITECTURE OVERVIEW


     
     Prizm UI Platform
    The mobile UI platform of Prizm is coupled with Canvas Graphics System
    a highly flexible graphics engine developed by MIZI Research.

     Prizm Application Suite
    Prizm is bundled with a fully-featured and mobile-optimized application suite. It includes everything from telephony¸ PIMS¸ multimedia apps to messaging client¸ utilities and games.

     Linux OS Integration
    Linux OS integration service is available upon customer’s request (including the development of device drivers for the target)








  • mount nfs command

    2008-04-15 17:12:18

    老是忘记mount nfs的命令

    mount -t nfs -o nolock 192.168.129.1:/root /tmp
  • vivi 命令使用说明

    2008-04-15 16:29:56

    在超级终端界面中键入任意键(除enter外)进入vivi命令界面

    vivi>

    输入help 可以见到开发板上的vivi 支持的命令

    vivi> help
    Usage:
           cpu [{cmds}]                             -- Manage cpu clocks
           bon [{cmds}]                             -- Manage the bon file system
           reset                                    -- Reset the system
           param [set|show|save|reset]              -- set/get parameter
           part [add|del|show|reset]                -- Manage MTD partitions
           mem [{cmds}]                             -- Manage Memory
           load {...}                               -- Load a file to RAM/Flash
           go <addr> <a0> <a1> <a2> <a3>            -- jump to <addr>
           dump <addr> <length>                     -- Display (hex dump) a range of memory.

           call <addr> <a0> <a1> <a2> <a3>          -- jump_with_return to <addr>
           boot [{cmds}]                            -- Booting linux kernel
           help [{cmds}]                            -- Help about help?
           display <vga|pal>                        -- Set the display format


           flash [{cmds}]                           -- Manage Flash memory
           wince [rewrite]                                  -- boot wince from ethernet or f
    lash by eboot

           os <linux|wince>                         -- set the default os

    mem命令 mem系列命令用于对系统的内存进行操作

    vivi> mem help 
    'mem' command usage: 
    ----------command parameter list----------- 
    mem size -- probe dram size 
    mem read <addr> -- read a word(4bytes) from special dram address 
    mem write <addr> <vlaue> -- write a word(4bytes) into special dram 
    address 
    mem test <start_addr> <size> [<quiet>] -- memory test 
    -----------sub command list------------- 
    mem cmp <dst_addr> <src_addr> <length> -- compare 
    mem copy <dst_addr> <src_addr> <length> -- copy memory from 
    <src_addr> to <dst_a 
    ddr> 
    mem info -- display memory infomation 
    mem reset -- reset memory control register 
    mem search <start_addr> <end_addr> <value> -- search memory address 
    that contain value in the special memory address range

    vivi>mem info

    RAM Information:                
    Default ram size: 64M                     
    Real ram size      : 64M
    Free memory        : 61M

    RAM mapped to              : 0x30000000 - 0x34000000     (SDRAM映射的地址范围) 
    Flash memory mapped to     : 0x10000000 - 0x12000000     (Flash映射的地址范围) 
    Available memory region : 0x30000000 - 0x33de4000      (用户可以使用的有效的内存区域地址范围) 
    Stack base address         : 0x33debffc      (栈的基地址) 
    Current stack pointer      : 0x33debc78       (当前栈指针的值)

    Memory control register vlaues      (S3C2410的内存控制寄存器的当前值) 
            BWSCON = 0x22111d10
          BANKCON0 = 0x00000700
          BANKCON1 = 0x00000700
          BANKCON2 = 0x00001f7c
          BANKCON3 = 0x00000700
          BANKCON4 = 0x00000700
          BANKCON5 = 0x00000700
          BANKCON6 = 0x00018001
          BANKCON7 = 0x00018001
           REFRESH = 0x008e01e9
          BANKSIZE = 0x000000b1
            MRSRB6 = 0x00000020
            MRSRB7 = 0x00000020
    vivi>

    load命令

    load 命令下载程序到存储器中(Flash或者 RAM中)过 load help 可
    以显示系统对 load系列命令的帮助提示  
    vivi> 
    load help 
    Usage: 
        load <flash|ram> [ <partname> | <addr> <size> ] <x|y|z|t>

             关键字参数 flash 和 ram 用于选择目标介质是 Flash还是 RAM
    到 Flash 中还是先要下载到 RAM 中(临时下载到 SDRAM 的起始地址处
    0x30000000保存一下,然后再转写入 FLASH),然后再通过 Flash驱动程
    序提供的写操作,将数据写入到 Flash中选择了 flash 参数,那名
    到底是对 NOR Flash操作还是对 NAND Flash操作,这取决于 bootloader
    编译的过程中,所进行的配置,这就要看配置的时候将MTD设备配置成NOR 
    Flash还是 NAND Flash  
             参数 partname 和 addr size二者选其一,partname是 vivi的 MTD分区表中
    的分区名 MTD分区的起始地址;addr和
    size是让用户自己选择下载的目标存储区域,而不是使用 vivi的 MTD分区,
    addr表示下载的目标地址,size表示下载的文件大小,单位字节,size参数
    不一定非要指定得和待下载的文件大小一样大,但是一定要大于等于待下载
    的文件的字节数  
             关键字参数 x y 和 z 分别表示从 PC主机上下载文件到 ARMer9系统中,
    采用哪种串行文件传送协议,x表示采用XModem协议,y表示采用Ymodem协议,z表示采用 ZModem协议请注意目前该 bootloader     vivi 还没有
    实现 ZModem协议,所以该参数只能选择 x和 y  

              关键字参数t应该是开发板vivi增加的,是tftp下载!很好用的!速度比jtag要快多了!

    开发板的vivi eboot烧写都要通过load命令

    如:要烧写eboot.nb0到flash的eboot分区,首先在超级中断进入vivi的shell,输入

    load     flash    eboot     t

    使用交叉网线连好PC与开发板,把eboot.nb0拷贝到于mtftp.exe同一目录下,在windows命令行输入

    mytftp     -i      192.168.0.15     PUT    eboot.nb0

    等待烧写完成即可

         param命令     param系列命令用于对 bootloader的参数进行操作 通过 param help可以
    显示系统对 param系列命令的帮助提示  

    vivi>param help

    Usage:
    param help                         -- Help aout 'param' command
    param reset                        -- Reset parameter table to default table
    param save                         -- Save parameter table to flash memeory
    param set <name> <value>           -- Reset value of parameter
    param set linux_cmd_line "..."     -- set boot parameter
    param set wince_part_name "..."            -- set the name of partition wich wince
    will be stored in
    param show                         -- Display parameter table
    vivi>

  • 一个资源比较多的网站,很多开发的教程

    2008-03-14 13:35:26

    http://www.cedn.cn/
  • 最近关注的几个Open source软件

    2008-02-04 17:06:57

    1.Webkit


    WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that's used by Safari, Dashboard, Mail, and many other OS X applications.

    (解读,所以说Webkit不光用来做浏览器引擎,还被用在一些应用程序中。至此我们是否可以这么理解:很多应用程序也可以用HTML,CSS等来组织外观?这么一来,未来很多程序都可以从网络上下载界面,甚至直接更新应用)

    WebKit's HTML and Javascrīpt code began as a branch of the KHTML and KJS libraries from KDE. This website is also the home of S60's S60 WebKit development.(看来Webkit还被S60所用)

    WebKit会被越来越广泛得采用,未来开源浏览器估计会很普遍,不管在桌面系统还是手持系统上。

    2.Gnome Mobile
    Gnome是知名的桌面linux应用软件包,现在针对移动设备的Gnome Mobile 也已经处在孵化器,估计很快会变成跟PC上一样普及。

    3. Debian Arm port

    Current Status

    Debian fully supports a port to little-endian ARM. Unofficial ports to big-endian ARM (armeb) and ARM EABI (armel) are underway.

    As of our latest release, Debian GNU/Linux 4.0r2, the following ARM sub-architectures are fully supported:

    Some sub-architectures have partial or incomplete support:

    • rpc: we provide a kernel and incomplete debian-installer support but this platform lacks testing.
    • s3c2410: we provide a kernel but there is no integration with debian-installer.
    我对Debian Arm port比较看好,感觉Deian对底层平台的开发非常注重。所以也想尝试改造一个"Debian Insided" PDA.




  • NTT DoCoMo将要发布在日本发布 Android 手机

    2008-02-04 15:29:46


    翻译Michael, 移动学堂 版权所有

    日 本是最有趣的移动手机市场之一。其增长速度很快,根据一个名为"ABI"研究小组的数据,预计会从2007年的18亿美元,增长到2013年的240亿美 元.NTT DoCoMo跟Google之间宣布合作加固了Google在移动广告市场的地位,而且也许会将基于Android平台的手机推向日本市场.

    NTT DoCoMo在全球移动设备公司中也算是个领头羊,总部设在东京,同时拥有全球最流行的移动email/网络服务i-mode.使用该服务的人有4800万.

     

    NTT DoCoMo Handsets

    该公司已经提供了一些列手机.都是通过与富士通等生产商合作推出的.包括: Raku-Raku PHONE Basic, Secure 3G FOMA F903iBSC, 3G FOMA 703i Series, D800iDS and SO903iTV.

    根据最新的移动消费调查数据,Open Handset Alliance具有的优势有:



    Google的Android平台是第一个能够重建日本移动生态系统的"正规"尝试.该平台的成功会给移动内容,服务,应用开发等领域带来空前的变革.尽管如此,离这个成功尚有路要走,很多问题有待解决.

     

    在日本市场,Google正在面临一些巨大的挑战,解决这些问题之后,Google 才能继续去"再生"全球移动生态系统". 日本国际大学的移动消费者研究所的Phlilp Sugai博士说道:

     

     

    尽 管Symbian和微软对Google的Android饱含批评的态度,Google现在面临的巨大挑战是: 如何跟MontaVista保持合作,如何推广其Android平台在linux开发社区.如果2008年Google做不到这些,那么可能 Android会被废弃,而且对Symbian或者微软都没有造成任何威胁了.
  • Nokia and maemo in the new GNOME mobile context

    2008-02-04 11:16:52

    http://www.slideshare.net/qgil/nokia-and-maemo-in-the-new-gnome-mobile-context/

  • Azingo - 新出炉的linux手机软件栈

    2008-02-03 10:56:48

    摘自linuxdevice 移动学堂  翻译 Michael@移动学堂 ootroo.com/zblog/


    Azingo 下个月将会将其基于linux的手机软件栈投放市场。"Azingo Mobile"软件栈将会在下个月的巴塞罗那移动世界大会(Mobile World Congress)展出。该软件栈针对中低端只能手机市场,由于其成熟性,Azingo已经加入Limo,将会成为Limo的主要软件提供者之一。

     

     

     

    之前的Cellunite一年前在阿姆斯特丹的"Open source in Mobile"会议上已经露脸。该公司设置在硅谷,但是研发主要在印度。总共大概250个工程师,计划接下来三年里能够稳步发展。该公司市场部的 Michael McLaughlin说。“我们将会扩展到1000人,600人做服务,400人做平台开发。我们会提供一些服务,比如根据客户的要求定义平台,跟运营商相关的软件包,或者移植客户的DRM,JVM到我们平台;我们还提供一些跟开源软件相关的服务“。

    1 月初的时候,Cellunite改名"Azingo",同时宣布它将为Limo的CIE(Common Integration Environment)提供软件工具,这样就开启了Azingo跟一些Limo成员厂商之间合作的窗口. Limo是一个业界的合作组织,现在已经有很多巨头加入,比如MOto,Samsung...Limo成员致力于共同开发应用软件。据说Azingo已经 雇佣了一个前moto经理专门负责MOto的项目。




    Azingo Mobile 捷图
    (Click to enlarge)


    Azingo Mobile
    Azingo Mobile软件栈定位为“第一个完整的linux手机软件栈“——从内核到应用软件,囊括了所有的软件。而且符合”Limo标准“。
    McLaughlin 说”我们是Limo活跃分子,我们认为Limo是linux 移动设备软件的一个核心力量“




    Azingo Mobile diagram
    (Click to enlarge)

    Azingo Mobile软件栈目前支持"来自6家巨头厂商的12个硬件平台“,CEO Mahesh Veerina在一个声明中说道。McLaughlin说大部分平台2.6.19内核已经完成。此外,Azingo也可以使用客户自己的内核,或者其他第 三方公司比如MontaVista,WindRiver的内核。“我们的合作伙伴可能有自己的内核,而且已经移植到自己的硬件平台上。我们对使用自己内核 的客户也有一套商业合作办法”。

    为了跟上“移动设备 使用桌面图形GUI的”趋势,AzingoMobile使用GTK作为GUI的底层构架。Azingo说,他们还提供丰富的多媒体应用,此外还包括一个 MIDP2.0的Java虚拟机,该虚拟机来自第三方,目前尚未得知具体消息。客户也可以增加自己的模块,当然需要签订一定的服务合同.

    也 许最有意思的是Azingo Mobile集成了开源的Webkit渲染引擎,该引擎也被用在Nokia S60系列智能手机系统以及iphone中. 这不光使得手机能够浏览网页,同时各种UI界面也可以通过HTML,CSS,AJAX等Web标准定制;甚至这些界面都可以通过网络进行下载,更新. 有了网络连接,各种各样的服务都能取得了,比如天气预报,交通信息,图像浏览等等.

    Azingo的竞争对手Trolltech正在移植Webkit(不过Nokia的收购服务不知道会对Trolltech产生什么影响).Moto也在去年的linux世界大会上表示了它将Web widgets集成进MotoDev Studio工具的意图.

    McLaughlin说Azingo还没有准备公布使用Mobile Stack的客户.不过他说,大概从现在开始到三月底,客户信息会不断发布.此外也将公布一些跟Limo合作的消息.

    Guido Arnone,沃达丰的技术总监说,Azingo Mobile的软件栈能够支持低端,支持网络功能的智能手机.这个使得Limo的目标:产业化更接近了.


  • linux潘多拉游戏宝盒

    2008-02-02 11:34:09


    翻译 Michael, 原文来自linuxdevices, 移动学堂版权所有 转载请注明"移动学堂"

    http://www.ootroo.com/zblog/

    基于linux的游戏设备悄然出现了.该设备支持wifi,USB具备800*480尺寸的LCD. "潘多拉"采用linux操作系统,运行于一款基于arm的SOC,并且包括OpenGL2.0标准的显示处理器.

    (点击察看大图)

    Spread the word:
    digg this story

    使用Li电池,尺寸5.5 x 3.3 x 1.1 英寸 -- 比任天堂的 DS Lite稍小,该产品是从一款名叫"GP2X player"产品演化而来.

    功耗上,这款产品根任天堂的Game Cube类似,但是该产品比GameCube多了无线连接功能.

    该 项目网站为OpenPandora.org,去年开通. 创始人CraigIX和EvilDragon原先就是Gamepark的GP2X游戏项目里出来的.当GamePark发布第二款linux游戏终端产品 GP2X F-200之后,两人便启动了这个项目. 所以该项目的定位就是"比GP2X的后继者","linux游戏终端的领头羊".

     

    因为直接在linux上运行的游戏不多,所以GP2X集成了各种模拟器,包括MAME,SNES,Genesis,以及PC Engine.这个做法让用户可以运行各种各样的游戏.潘多拉最初会先全速支持PS1的模拟,然后计划一直N64

     


    Pandora keyboard
    (Click to enlarge)


    潘多拉使用TI的OMAP3430,第一款使用65纳米技术的SOC芯片,也是第一个使用arm Cortex-A8构架内核的SOC芯片.根据arm公司说,Cortex-A8的性能可以达到ARM11的3倍.

     



    潘多拉(后面,盒盖状态)

    OMAP3430 内置一款名叫PowerVR SGX的显示内核(来自Imagination Technologies),使得它成为第一款支持OPENGLES 2.0和OPENVG的应用处理器芯片(AP). PowerVRSGX采用低功耗设计,用来在移动设备上处理3D图像和视频.据说,OpenGL ES 2.0标准定义了每秒处理百万个多边形的速度.可见有多快了. 该芯片还采用了多线程的引擎技术,使得可以编解码DVD分辨率的视频.


    OMAP3430 构架
    (Click to enlarge)


    潘 多拉使用128MB DDR SDRAM以及256MB内部FLASH,支持4.3英寸显示(5比3).包括802.11g wifi, USB Host, 双SDHC插槽,还有串口(估计是用来接手柄);此外还有QWERTY键盘,麦克风等收入设备;TV-out,A/V-out,耳机等输出设备. 游戏控制是通过键盘上方的按钮(参考照片).

     




    PowerVR SGX architecture
    (Click to enlarge)


    据说,潘多拉使用"Open2x"linux;也同时可能支持Debian Arm包.Open 2x是为GP2x设计的linux系统,采用2.4.26内核;在OMAP3430上,将会使用一个更新的版本.(至少要2.6吧)

     

    潘多拉可以运行X11,包括窗口管理器以及桌面环境;还有包括一些应用,比如Firefox3.0,Macromedia Flash可能还不能用. 但是他们说大部分Flash视频都可以通过Gnash收看;将会使用Mplayer和VLC作为播放器.


    Pandora (red model)
    (Click to enlarge)

    是潘多拉的配置

    • 处理器-- TI OMAP3430 with PowerVR SGX GPU
    • 内存-- 128MB DDR SDRAM; 256MB internal flash
    • 存储扩展-- 2 x SDHC
    • 显示-- 4.3 inch 触摸屏LCD  800x480 分辨率and 5:3 aspect ratio; 300 cd/m2 亮度; 450:1 对比率
    • 连接-- 802.11g WiFi, USB host, RS232 serial
    • A/V I/O -- TV-out (支持画中画); A/V-OUT (S-Video and Composite); 3.5mm 耳机麦克风
    • 其他特性 -- 游戏方向键; 2 x 游戏按钮, 时钟
    • 尺寸-- 5.5 x 3.3 x 1.1 英寸(140 x 83 x 27 mm)
    • 电池-- Lithium-ion; 支持电源适配器和USB充电
    • 操作系统 -- 类Open2X Linux



    Pandora (front, detail)
    (Click to enlarge)


    什么时候能买到

    4,5月份上市,价格大概320美元,或者286欧元,更多信息见网站 developer-oriented page, 官方网站 OpenPandora site 正在搭建中

     

  • Gos体验

    2008-02-01 10:40:55

    早上从sanool的圈子里看到袁萌老师的blog http://www.lupaworld.com/64092,得知现在有个“云雾计算”的东西,后来又看到了gOS,gPC.

    在http://thinkgos.com/官方网站上看到gOS的一个screenshot,很像苹果的UI。
     
      这个发行的版本已经集成了很多应用,比如google桌面,gmail,gtalk,blogspot,facebook...很多应用,好像大多数都是针对网络的。

      gOS由unbuntu7+enlightenment构成,界面很漂亮!崇尚个性化的人士应该会喜欢(我很喜欢这个系统)


    我觉得它强调的功能就是“on-line"。这个可是向微软vista桌面系统的一个不小的宣战哦

      下载地址http://underground-server.com/welcome/?page_id=5
  • bugzilla安装以及使用

    2008-01-25 15:46:08

    1.下载
    1.1下载bugzilla
    我使用的版本是bugzilla-2.20.4
    下载地址 http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-2.20.4.tar.gz

    1.2下载perl5.8.2
    http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.2.808-MSWin32-x86.msi

    该版本的bbm是命令界面的,即安装说明http://www.bugzilla.org/docs/win32install.html所用的版本






    2. 安装
    step 1 先安装perl
    下载的perl版本是直接运行安装的msi格式
    step 2 再安装 bugzilla需要的perl module



    C:\>ppm

    PPM - Programmer's Package Manager version 3.1.
    Copyright (c) 2001 ActiveState Corp. All Rights Reserved.
    ActiveState is a devision of Sophos.

    Entering interactive shell. Using Term::ReadLine::Stub as readline library.

    Type 'help' to get started.

    ppm> rep add Bugzilla http://landfill.bugzilla.org/ppm
    Repositories:
    [1] ActiveState PPM2 Repository
    [2] ActiveState Package Repository
    [3] Bugzilla
    ppm> install AppConfig
    ====================
    Install 'AppConfig' version 1.52 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 50508 bytes.
    ...
    Successfully installed AppConfig version 1.52 in ActivePerl 5.8.7.813.
    ppm> install TimeDate
    ====================
    Install 'TimeDate' version 1.16 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 19235 bytes.
    ...
    Successfully installed TimeDate version 1.16 in ActivePerl 5.8.7.813.
    ppm> install DBI
    ====================
    Install 'DBI' version 1.43 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 508164 bytes.
    ...
    Successfully installed DBI version 1.43 in ActivePerl 5.8.7.813.
    ppm> install DBD-mysql

    ====================
    Install 'DBD-mysql' version 2.9002 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 178803 bytes.
    ...
    Successfully installed DBD-mysql version 2.9002 in ActivePerl 5.8.7.813.
    ppm> install Template-Toolkit
    ====================
    Install 'Template-Toolkit' version 2.13 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 530770 bytes.
    ...
    Successfully installed Template-Toolkit version 2.13 in ActivePerl 5.8.7.813.
    ppm> install MailTools
    ====================
    Install 'MailTools' version 1.67 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 46881 bytes.
    ...
    Successfully installed MailTools version 1.67 in ActivePerl 5.8.7.813.
    ppm> install GD
    ====================
    Install 'GD' version 2.07 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 363039 bytes.
    ...
    Successfully installed GD version 2.07 in ActivePerl 5.8.7.813.
    ppm> install Chart
    ====================
    Install 'Chart' version 2.3 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 58641 bytes.
    ...
    Successfully installed Chart version 2.3 in ActivePerl 5.8.7.813.
    ppm> install GDGraph
    ====================
    Install 'GDTextUtil' version 0.86 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 19178 bytes.
    ...
    Successfully installed GDTextUtil version 0.86 in ActivePerl 5.8.7.813.
    ====================
    Install 'GDGraph' version 1.43 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 71764 bytes.
    ...
    Successfully installed GDGraph version 1.43 in ActivePerl 5.8.7.813.
    ppm> install PatchReader

    ====================
    Install 'PatchReader' version 0.9.4 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 9558 bytes.
    ...
    Successfully installed PatchReader version 0.9.4 in ActivePerl 5.8.7.813.
    ppm> install Net::LDAP

    ====================
    Install 'Convert-ASN1' version 0.19 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 26326 bytes.
    ...
    Successfully installed Convert-ASN1 version 0.19 in ActivePerl 5.8.7.813.
    ====================
    Install 'perl-ldap' version 0.33 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 188548 bytes.
    ...
    Successfully installed perl-ldap version 0.33 in ActivePerl 5.8.7.813.
    ====================
    Install 'Net-LDAP-Express' version 0.11 in ActivePerl 5.8.7.813.
    ====================
    Downloaded 7693 bytes.
    ...
    Successfully installed Net-LDAP-Express version 0.11 in ActivePerl 5.8.7.813.
    ppm>
    step 3 安装服务器
    安装apache服务器,mysql服务器
    最快的方法就是使用wamp
    http://www.wampserver.com/en/download.php
    安装,运行

    step 4 配置apache服务器
    点击右下角图标,在APACHE里可以找到一个httpd.conf,这个就是我们需要配置的文件
    image menu WampServer

    如何配置(引用一下Byron Jones的《Installing Bugzilla on Microsoft Windows》)

    编辑文件C:\Program Files\Apache Group\Apache2\conf\httpd.conf 


    添加Configure CGI
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "C:/wamp/www/">

    Configure CGI

    添加 AddHandler cgi-scrīpt .cgi

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scrīpts outside of scrīptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    AddHandler cgi-scrīpt .cgi

    添加ExecCGI使得.cgi文件脚本可以被perl执行

    修改
    AllowOverride None
    AllowOverride All.
    修改scrīptInterpreterSource,使得apache服务器可以知道到哪里调用perl
    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "C:/Bugzilla">

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important. Please see
    # http://httpd.apache.org/docs-2.0/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

    #
    # Tell Apache to use Perl to execute .cgi
    #
    scrīptInterpreterSource Registry-Strict


    </Directory>

    You also should add index.cgi to the DirectoryIndex list.

    #
    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    # The index.html.var file (a type-map) is used to deliver content-
    # negotiated documents. The MultiViews Option can be used for the
    # same purpose, but it is much slower.
    #
    DirectoryIndex index.html index.html.var index.cgi

    编辑注册表,添加.cgi键

    Create a key HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command with the default value of the full path of perl.exe with a -T parameter. For example C:\Perl\bin\perl.exe -T

    regedit screenshot

    Step 5 创建数据库

    进入win command,进入mysql所在目录
    cd c:\wamp\bin\mysql\bin\

    运行

    c:\wamp\bin\mysql\bin>mysql --user=root -p mysql
    Enter password: ********
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 15 to server version: 4.0.20a-debug

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> create database bugs;

    Query OK, 1 row affected (0.11 sec)

    mysql> grant all privileges on bugs.* to 'bugs'@'localhost' identified by 'sockmonkey';
    Query OK, 0 rows affected (0.03 sec)

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> quit

    Bye
    这样,数据bugs创建了,同时创建了一个用户,名为bugs,密码为sockmonkey

    Step 6 修改bugzilla的localconfig,注意数据库的名字,用户名字,密码
    #
    # How to access the SQL database:
    #
    $db_host = 'localhost';         # where is the database?
    $db_name = 'bugs';              # name of the SQL database
    $db_user = 'bugs';              # user to attach to the SQL database

    # Sometimes the database server is running on a non-standard
    # port. If that's the case for your database server, set this
    # to the port number that your database server is running on.
    # Setting this to 0 means "use the default port for my database
    # server."
    $db_port = 0;



    #
    # Enter your database password here. It's normally advisable to specify
    # a password for your bugzilla database user.
    # If you use apostrophe (') or a backslash (\) in your password, you'll
    # need to escape it by preceding it with a '\' character. (\') or (\)
    # (Far simpler just not to use those characters.)
    #
    $db_pass = 'sockmonkey';

    step 7.运行安装脚本
    将bugzilla解压缩到c:\wamp\www\bugzilla(假设wamp是安装在c:\wamp)

    进入bugzilla目录,运行
    c:\wamp\www\bugzilla\>perl checksetup.pl


    4. 使用
    打开浏览器,运行http://localhost/bugzilla/
    就可以看到bugzilla的界面
  • 手机上的flash播放器

    2008-01-24 13:50:55

        好像我跟flash播放器很有缘.
        刚买电脑的时候第一个安装的程序就是Macromedia Flash 4.0.当然那个时候Macromedia公司知名度已经有了,互联网上的flash动画也已经很多了.
        于是我开始作动画,做了很多. 有个女孩子生日,我也作了一个生日卡片,很有意思.
        工作之后,从事手机开发,我也想到了在手机上实现flash播放. 调研过一段时间,那个时候Macromedia公司刚出了flash lite 1.0, 我还打电话到他们北京的office,可是好几次都没有接通.
        后来买了一个PDA,发现网上针对wince 已经有现成的lib跟应用了.

        现在还在关注这个事情,希望能在我的开发板上播放flash,或者直接访问youtube.
        如果要使用开源的东西,那么可以用gnash,现在已经能支持swf v7标准的flash动画文件,甚至流文件
        发现Nokia 的meamo已经porting 了firefox,支持flash player 9.
       
  • 手机也可以open source和DIY

    2008-01-21 09:18:46

    见http://www.opencellphone.org/
401/212>
Open Toolbar