- 博客(49)
- 资源 (3)
- 收藏
- 关注
原创 内核ACPI函数API之acpi_has_method
acpi_has_method(acpi_handle handle, char *name) 用于判断handle 是否提供形参name指定的method其使用的例程如下: if (!acpi_has_method(adev->handle, "_DEP")) return false;例如这个例子就是判断adev->handle 是提供_DEP 这个函数其源码分析如下:...
2018-03-28 00:28:46 894
原创 内核ACPI函数API之acpi_evaluate_integer
acpi_evaluate_integer 这个函数用于从bios中获取一个字符串的值其使用的例程如下: status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, &ac->state); if (ACPI_FAILURE(status)) { ACPI_EXCEPTI...
2018-03-28 00:04:46 1785
原创 内核设备驱动API之__register_chrdev_region
__register_chrdev_region用于注册一个一个单独的主设备号和一个范围内的从设备号其源码分析如下:static struct char_device_struct *__register_chrdev_region(unsigned int major, unsigned int baseminor, int minorct, const char *name...
2018-03-23 21:06:29 1106 2
原创 内核设备驱动API之register_chrdev
register_chrdev用于注册一个字符设备。其源码分析如下:static inline int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops){ #这里设置最小的字符设备号和最大的设备号后,调用下面的函数继续注册 return __reg...
2018-03-23 20:16:39 460
原创 内核设备驱动API之get_device和put_device
struct device *get_device(struct device *dev) 这个函数用于增加形参device 的引用计数一般和put_device 配合使用其源码分析如下:struct device *get_device(struct device *dev){ return dev ? kobj_to_dev(kobject_get(&dev->kobj...
2018-03-23 17:17:25 4510
原创 内核设备驱动API之device_rename
int device_rename(struct device *dev, const char *new_name)用于给已经存在设备重新命令。其源码分析如下:int device_rename(struct device *dev, const char *new_name){ struct kobject *kobj = &dev->kobj; char *old_d...
2018-03-23 16:32:19 685
原创 内核设备驱动API之device_add
int device_add(struct device *dev)用于添加一个设备到linux的设备数其源码分析如下:int device_add(struct device *dev){ struct device *parent; struct kobject *kobj; struct class_interface *class_intf; int error = -EIN...
2018-03-21 11:05:55 1244
原创 内核设备驱动API之cdev_add
int cdev_add(struct cdev *p, dev_t dev, unsigned count)用于添加一个字符设备到系统其使用的例程如下: err = cdev_add(cdev, MKDEV(cd->major, baseminor), count); if (err) goto out;其源码分析如下:int cdev_add(struct cdev *p,...
2018-03-21 11:04:32 2613
原创 内核设备驱动API之__class_create
struct class *__class_create(struct module *owner, const char *name, struct lock_class_key *key)用于动态创建设备的逻辑类,并完成字段的初始化,并在/sys/class 下新建一个目录。其使用的例程如下:#define class_create(owner, name) \({ ...
2018-03-20 21:14:08 783
原创 内核文件系统API之vfs_statfs
int vfs_statfs(const struct path *path, struct kstatfs *buf) 用于返回形参path 表示的文件的mount point和super block的有效flags返回的结果保存在形参buf中其结构体如下:struct kstatfs { long f_type; long f_bsize; u64 f_blocks; u64 f...
2018-03-20 19:29:41 1373
原创 内核文件系统API之vfs_getattr
int vfs_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags)用于得到文件的 enhanced basic attributes 即基本的扩展属性其源码分析如下:int vfs_getattr(const struct path *path, ...
2018-03-20 19:22:45 1625
原创 内核文件系统API之vfs_stat
static inline int vfs_stat(const char __user *filename, struct kstat *stat)用于查找形参filename 代表的文件的属性信息,将其保存到形参stat中返回给用户其源码分析如下:static inline int vfs_stat(const char __user *filename, struct kstat *st...
2018-03-20 19:21:21 3698
原创 _OSI("Windows 2001")在linux 平台上回返回2,不要用OSI 区分window和linux
当在bios中调用_OSI("Windows 2001") 来确实当前系统是否是window时,这个用法是错误的。但是linux中对OSI的实现函数如下:acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state){ /* Lookup the interface in the global _OSI l...
2018-03-16 19:22:34 675 1
原创 不要使用_OS ,_OSI ,_REV来区分windows还是linux
再bios中经常有人通过下面的语句判断当前系统是linux _OSI("Linux") 还是window _OSI("Windows 2001") 目前这两个都是在BIOS中返回true有的bios还使用_REV 来区分window还是linux ,window 中_REV=2,但是在linux中 _REV也是等于2所以结论就是不用使用_OS ,_OSI ,_REV来区分windows还是li...
2018-03-16 18:58:29 1131
原创 内核文件系统API之unshare_fs_struct
int unshare_fs_struct(void)用于跟当前task的fs_struct设置新值,实现不共享copy其源码分析如下:int unshare_fs_struct(void){ struct fs_struct *fs = current->fs; #申请新的fs_struct struct fs_struct *new_fs = copy_fs_struct(f...
2018-03-16 08:54:58 641 1
原创 内核文件系统API之register_filesystem和unregister_filesystem
int register_filesystem(struct file_system_type * fs)用于注册一个新的文件系统其源码分析如下:int register_filesystem(struct file_system_type * fs){ int res = 0; struct file_system_type ** p; #文件系统的名字中不能含有'.' BUG_O...
2018-03-16 08:54:04 1239
原创 内核文件系统API之put_unused_fd
void put_unused_fd(unsigned int fd)用于将形参对应的fd在其文件系统打开文件的bitmap中清零。其源码分析如下:void put_unused_fd(unsigned int fd){ #得到当前进程对应文件管理结构体 struct files_struct *files = current->files; #操作bitmap时需要spinloc...
2018-03-15 09:15:45 709
原创 内核文件系统API之notify_change
int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **delegated_inode)用于检查文件系统attribute的改动是否有效,有效的话,就通知文件系统这个改动,无效的话就返回error其源码分析如下:int notify_change(struct dentry * dentry,...
2018-03-15 09:14:51 1555
原创 内核文件系统API之new_inode
struct inode *new_inode(struct super_block *sb)用于在形参给定的super_block上申请一个新的inode其源码分析如下:struct inode *new_inode(struct super_block *sb){ struct inode *inode; spin_lock_prefetch(&sb->s_inode...
2018-03-14 09:03:50 1131
原创 内核文件系统API之mnt_want_write
int mnt_want_write(struct vfsmount *m)获得一个mount点的写权限其源码分析如下:int mnt_want_write(struct vfsmount *m){ int ret; #标志开始对super block开始写 sb_start_write(m->mnt_sb); #检查mnt是否持有MNT_WRITE_HOLD 或者是否只读,如...
2018-03-14 09:03:03 918
原创 内核文件系统API之may_umount_tree
int may_umount_tree(struct vfsmount *m)用于检查文件装载树中的mnt结构体是否busy。其源码分析如下:int may_umount_tree(struct vfsmount *m){ #mount point 是否busy最终都是检查mount point,因此这里通过real_mount 将vfs_mount #转成mount 结构体 str...
2018-03-13 09:00:28 337
原创 内核文件系统API之may_umount
int may_umount(struct vfsmount *mnt)用于判断文件系统的mount point是否busy其源码分析如下:int may_umount(struct vfsmount *mnt){ int ret = 1; down_read(&namespace_sem); lock_mount_hash(); #检查mount point是否busy 要...
2018-03-13 08:59:01 370
原创 redis中io复用之select
前面讲过evport/epoll/kqueue的实现,下来我们继续看看我们select在redis中的使用1:首先通过FD_ZERO来清空用于监控读和写fd的rfds和wfds的链表typedef struct aeApiState { fd_set rfds, wfds; /* We need to have a copy of the fd sets as it's not...
2018-03-12 17:10:00 931
原创 redis中io复用之kqueue
前面讲过evport/epoll的实现,下来我们继续看看我们kqueue在redis中的使用1:首先通过kqueue申请提供给系统监控的fdtypedef struct aeApiState { int kqfd; struct kevent *events;} aeApiState;static int aeApiCreate(aeEventLoop *eventLoo...
2018-03-12 16:33:30 850
原创 redis中io复用之epoll
前面讲过evport的实现,下来我们继续看看我们epoll在redis中的使用1:首先通过epoll_create 来新建fd例如:typedef struct aeApiState { int epfd; struct epoll_event *events;} aeApiState;static int aeApiCreate(aeEventLoop *eventLo...
2018-03-12 15:31:13 921
原创 内核文件系统API之invalidate_inodes
int invalidate_inodes(struct super_block *sb, bool kill_dirty)用于将超级块sb上的inode 设置为无效 其源码分析如下: int invalidate_inodes(struct super_block *sb, bool kill_dirty) { int busy = 0; struct ino...
2018-03-12 09:02:56 455
原创 内核文件系统API之make_bad_inode
void make_bad_inode(struct inode *inode)当inode上发生IO error的时候,可以通过这个函数将这个inode设置为bad inode其源码分析如下:void make_bad_inode(struct inode *inode){ remove_inode_hash(inode); inode->i_mode = S_IFREG; ...
2018-03-12 09:00:12 432
原创 内核文件系统API之inode_add_bytes
void inode_add_bytes(struct inode *inode, loff_t bytes)函数用于增加inode的byte数其源码分析如下:void inode_add_bytes(struct inode *inode, loff_t bytes){ spin_lock(&inode->i_lock); __inode_add_bytes(inode,...
2018-03-09 08:58:26 360
原创 内核文件系统API之iget_locked
struct inode *iget_locked(struct super_block *sb, unsigned long ino)用于根据super_block和inode id 找到inode其源码分析如下:struct inode *iget_locked(struct super_block *sb, unsigned long ino){ struct hlist_head ...
2018-03-09 08:57:19 1396
原创 spark的RDD
spark的RDD 分为两种操作,分别是actions和transformations首先生成一个RDD执行action执行transformations
2018-03-08 17:23:51 386
原创 HIbench
HIbench 是一个大数据的benchmark测试的套件,用来测试框架的速度,吞吐率,资源利用率等。其网站是https://github.com/intel-hadoop/HiBench其支持的框架如下:我这边以spark测试为例下载Hibench https://github.com/intel-hadoop/HiBenchHibench 遇到下面问题
2018-03-08 16:14:37 3564
原创 hsdf的使用
下载hadoopwget -c http://apache.fayea.com/hadoop/common/stable/hadoop-2.9.0.tar.gz解压tar -zxvf hadoop-2.9.0.tar.gz运行hadoop version配置hdfs启动hsfs只要下面一个命令就可以了启动hdfs的命令如下: ./sbin/start-dfs.sh启动成后就可以通过hdfs dfs...
2018-03-08 16:01:42 1439
原创 spark的安装和使用
1.首先检查是否安装了java和scala可以通过java -version检查java是否成功安装可见通过检测scala 检查scala是否成功安装下载spark wget http://mirror.bit.edu.cn/apache/spark/spark-2.3.0/spark-2.3.0-bin-hadoop2.7.tgz解压tar -zxvf s
2018-03-08 15:53:12 1481
原创 内核文件系统API之I_BDEV
struct block_device *I_BDEV(struct inode *inode)的作用是根据inode返回其对应的block_device其源码分析如下:struct block_device *I_BDEV(struct inode *inode)52 {53 return &BDEV_I(inode)->bdev;54 }46 static inli...
2018-03-08 08:59:44 572
原创 内核文件系统API之get_super
struct super_block *get_super(struct block_device *bdev)用于获得形参block_device对应的super_block其源码分析如下:struct super_block *get_super(struct block_device *bdev){ #第二个形参false代表是对这个设备进行读操作 return __get_sup...
2018-03-08 08:58:44 562
原创 内核文件系统API之get_max_files
unsigned long get_max_files(void)用于得到系统中已经打开的文件数其源码分析如下:unsigned long get_max_files(void){ return files_stat.max_files;}可见这里是直接通过files_stat 这个全局变量得到的这个值平时可以通过sysctl得到 { .procname = "file-max...
2018-03-07 09:15:31 407
原创 内核文件系统API之get_fs_type
struct file_system_type *get_fs_type(const char *name) 用于查找形参指定的文件系统,并返回file_system_type类型其中file_system_type的定义如下:struct file_system_type { const char *name; int fs_flags;#define FS_REQUIRES_DEV
2018-03-07 09:14:53 1677
原创 内核文件系统API之get_empty_filp
struct file *get_empty_filp(void)函数的功能是获得一个未使用的文件缓存空间即file结构体其源码分析如下:struct file *get_empty_filp(void){ const struct cred *cred = current_cred(); static long old_max; struct file *f; int error;
2018-03-06 08:58:06 988
原创 内核文件系统API之generic_fillattr
void generic_fillattr(struct inode *inode, struct kstat *stat) 用于根据形参inode给形参kstat赋值,这里的kstat表示的kernel state其源码分析如下:void generic_fillattr(struct inode *inode, struct kstat *stat){ stat->dev = inod
2018-03-06 08:57:20 839
原创 redis中io复用之evport
从redis中的ae.c中可以知道目前复用io的方式有下面四种#ifdef HAVE_EVPORT#include "ae_evport.c"#else #ifdef HAVE_EPOLL #include "ae_epoll.c" #else #ifdef HAVE_KQUEUE #include "ae_kqueue.c" ...
2018-03-05 09:46:05 3391
EDK_II_UserManual_0_7.pdf
2017-03-24
EDK_II Module Writer_s Guide_0_7.pdf
2017-03-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人