A demo using mmap to read a file Thursday, September 8, 2011

#include
  #include
  #include
  #include
  #include
  #include

  int main (int argc, char *argv[])
  {
          struct stat sb;
          off_t len;
          char *p;
          int fd;

          if (argc < 2) {
                  fprintf (stderr, "usage: %s \n", argv[0]);
                  return 1;
          }

          fd = open (argv[1], O_RDONLY);
          if (fd == -1) {
                  perror ("open");
                  return 1;
          }

          if (fstat (fd, &sb) == -1) {
                  perror ("fstat");
                  return 1;
          }

          if (!S_ISREG (sb.st_mode)) {
                  fprintf (stderr, "%s is not a file\n", argv[1]);
                  return 1;
          }

          p = mmap (0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
          if (p == MAP_FAILED) {
                  perror ("mmap");
                  return 1;
          }

          if (close (fd) == -1) {
                  perror ("close");
                  return 1;
          }

          for (len = 0; len < sb.st_size; len++)
                  putchar (p[len]);

          if (munmap (p, sb.st_size) == -1) {
                  perror ("munmap");
                  return 1;
          }

          return 0;
  }

create_singlethread_workqueue

struct workqueue_struct *create_singlethread_workqueue(const char *name);

Creates a workqueue. Each workqueue has one dedicated processes ("kernel threads"), which run functions submitted to the queue.

Timeline of Linux Kernel Thursday, August 11, 2011


Project charter 翻译自rita

项目章程包含什么

许多公司要求项目章程包含诸如详细的日程安排表、完整的风险分析等等,但这类信息在项目管理的启动阶段是无法获得的。项目章程不是项目管理计划。

项目名称和描述(这个项目是什么)

客户满意度修复项目
在过去的几个月里面,质量管理部门发现,很多客户在我们的计算机网络上订购XYZ设备花费的时间要比用竞争对手的多十倍。这个项目的目的就是调查原因并且提出一个解决方案。这个解决方法将会作为后续的项目。质量控制部门能提供详细的记录,可以帮助当前项目。

项目经理任命以及授权水平(谁被授权领导这个项目,他/她是否有权利决定、管理和批准对于预算、日程、项目组成员组成等问题的变更?)

比如,Alexis Sherman是项目经理,有权利挑选项目组成员,决定项目的最终预算。

业务需要或者业务驱动力(为什么考虑在某个时候要做这个项目?)

这个项目的目的是避免客户满意度的下滑趋势。

项目的合理性(业务分析,基于财务或者其他基础,解释这个项目的合理性)

我们期待改善的客户满意度会在第一年为公司增加至少200,000美元的收入,由于减少服务电话的数目。附带的效益是,我们期待这个项目在修复问题的同时能够得到持续改善客户满意度的方法。

资源预备 (能提供什么资源以及多少?)

Morgan Kolb和Danny Levins全部时间投入这个项目,因为他们熟悉这类计算机网络。其他资源将由项目经理决定。

项目干系人(当前已知的,谁会影响、或者被影响?)

项目干系人包括:Connor,来自质量控制;Ruth,客户服务;Mary,市场。这些资源有助于项目经理管理项目。

项目干系人的需求(项目和产品范围相关的需求)

项目章程的附件包含现有系统的详细说明以及现有系统能满足的需求。当前项目不会改变现有的需求。
项目必须利用质量控制部的数据。

产品描述/交付物(具体的交付物是什么以及项目的结果是什么?)

  • 一份报告。
报告概述:什么能被改变、每个改变的成本以及每个改变会在客户下订单方面能节省多少时间。
  • 一份必须完成的改变的清单。
一个WBS大体列出两个星期期限内完成项目的计划,以及一个星期后影响项目完成的风险清单。

约束和假设

在9月1日前完成项目。预算¥5000以内。我们认为Kerry会全程辅助这个项目。测试是在供应商的计算机上完成。
约束就是固有的限制条件,比如只有5个人可用等;但是假设意味着不确定,可能正确也可能不正确。

项目章程对项目经理有什么用

不要低估项目章程的作用。项目章程是非常重要的文档,没有它就不能开始项目。项目章程就是项目目标、度量成功的定义,那么没有项目章程,项目和项目经理就不能成功。
项目章程至少有下面这些益处:
  • 正式认可(批准)项目的存在或者建立项目。
这意味着一个项目不能没有项目章程。没有项目章程,项目就不存在。
  • 给项目经理授权花钱和使用公司的资源。
  • 定义项目的粗略需求。(因此,当项目后续进行发生较小变更的时候,项目章程不一定改变。但反过来,当发生影响项目章程的变化的时候,就会面对项目是否还要继续的问题了。)
  • 把项目和组织正在进行的工作联系起来。
项目章程
  • 是发起人发起,而不是项目经理发起
  • 在启动过程组创建
足够广发以至于不需要项目变化而改变。
任何对项目章程的改变都需要考虑项目是不是继续进行。

most-used and must-known shortkey for terminal on ubuntu Wednesday, March 30, 2011

Ubuntu shortkey in terminal

ctrl+a or Home

Moves the cursor to the start of a line.

ctrl+e or End
Moves the cursor to the end of a line.

ctrl+b
Moves to the beginning of the previous or current word.

ctrl+k
Deletes from the current cursor position to the end of the line.

ctrl+u
Deletes the whole of the current line.

ctrl+w
Deletes the word before the cursor.

Issue when using identi.ca API Tuesday, March 22, 2011

When I used identi.ca API, "https://identi.ca/api/statuses/update.format", by Python2.6, an error returns from identi.ca server:

You must validate your email address before posting.

It's because I does not confirm the email from identi.ca after registered.

overview of android log system Wednesday, March 9, 2011

The bellowing diagram is from Tetsuyuki Kobabayshi.

It clearly illustrates the mechnisam of logging system and relationship among every attendee. Most of source code are rasided in system/core

Note: system buffer just occurs on Android 2.3.x or later.