当前位置: 首页 > news >正文

php网站开发培训学校外贸订单怎样去寻找

php网站开发培训学校,外贸订单怎样去寻找,政府网站开发的目的,怎么可以建网站文章目录 1. 设备管理模型2. 基本数据结构2.1 kobject2.2 kset 1. 设备管理模型 设备模型是内核提供的一个编写驱动的架构。 设备管理是设备-总线-驱动结构。 linux中的设备是由树状模型组织的,从sysfs中可以查看树状结构。 他本身实现了: 电源管理热…

文章目录

  • 1. 设备管理模型
  • 2. 基本数据结构
    • 2.1 kobject
    • 2.2 kset

1. 设备管理模型

设备模型是内核提供的一个编写驱动的架构。
设备管理是设备-总线-驱动结构。
linux中的设备是由树状模型组织的,从sysfs中可以查看树状结构。

他本身实现了:

  • 电源管理
  • 热插拔(hotplug)事件管理

2. 基本数据结构

  • kobject, kset, uevent
  • device, device_driver, bus, class

2.1 kobject

许多内核对象都是由kobject作为基类派生的。相同类型的kobject通过其内嵌的list_head链成一个链表,然后使用另外一个结构体kset(kobject的子类)来指向和管理这个列表。

struct kobject {const char		*name;struct list_head	entry;struct kobject		*parent;struct kset		*kset; 		/* 给相关的kobject分组,是kobj的集合 */struct kobj_type	*ktype; /* 抽象出了一些kobj和sysfs的通用接口,描述kobj的行为 */struct kernfs_node	*sd; 	/* sysfs 的文件节点 */struct kref		kref; 		/* kobject的引用计数 */
#ifdef CONFIG_DEBUG_KOBJECT_RELEASEstruct delayed_work	release;
#endifunsigned int state_initialized:1;unsigned int state_in_sysfs:1;unsigned int state_add_uevent_sent:1;unsigned int state_remove_uevent_sent:1;unsigned int uevent_suppress:1;
};

一个新的kobject要加入到设备管理模型中,需要使用函数:

/* 创建新的kobj */
struct kobject * __must_check kobject_create_and_add(const char *name,struct kobject *parent); 
/* parent : 在sysfs中的父目录,如果为NULL则表示在"/sys/"目录下 *//* 添加已存在的的kobj */						
int kobject_init_and_add(struct kobject *kobj,struct kobj_type *ktype, struct kobject *parent, const char *fmt, ...); 
/* fmt一般是name, 也是sysfs中kobject对应的目录名 */ 

调用之前需要给kobj分配内存,并初始化ktype,用于这个kset中kobject的通用操作,其中ktype如下:

struct kobj_type {void (*release)(struct kobject *kobj); 	/* 必须 */const struct sysfs_ops *sysfs_ops; 		/* 内含show和store接口 */struct attribute **default_attrs; 		/* 每个属性都在sysfs中有对应的属性文件 */const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);const void *(*namespace)(struct kobject *kobj);
};

2.2 kset

kset用于:

  • 作为一组kobject的容器
  • 是一个sysfs中的目录,里面包含kset关联的kobject
  • kset可支持kobject的“热插拔”,并影响uevent事件像用户空间的报告方式
/*** struct kset - 一个子系统中,一系列kobject的集合** A kset defines a group of kobjects.  They can be individually* different "types" but overall these kobjects all want to be grouped* together and operated on in the same manner.  ksets are used to* define the attribute callbacks and other common events that happen to* a kobject.** @list: the list of all kobjects for this kset* @list_lock: a lock for iterating over the kobjects* @kobj: the embedded kobject for this kset (recursion, isn't it fun...)* @uevent_ops: the set of uevent operations for this kset.  These are* called whenever a kobject has something happen to it so that the kset* can add new environment variables, or filter out the uevents if so* desired.*/
struct kset {struct list_head list;spinlock_t list_lock;struct kobject kobj;const struct kset_uevent_ops *uevent_ops;
} __randomize_layout;

一个组织多个kobject的kset例程(节选):linux/samples/kobject/kset-example.c

#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>MODULE_LICENSE("GPL");struct foo_obj {struct kobject kobj;int foo;int baz;int bar;
};
/* 从类型为kobj的结构体成员的指针x,获取该foo_obj类型结构体的指针 */
#define to_foo_obj(x) container_of(x, struct foo_obj, kobj)static void foo_release(struct kobject *kobj)
{struct foo_obj *foo;foo = to_foo_obj(kobj);kfree(foo);
}/* 可以定义所属kset的kobject的一些行为到default_attrs和sysfs_ops属性中,现在仅* 使用release */
static struct kobj_type foo_ktype = {// .sysfs_ops = &foo_sysfs_ops,.release = foo_release,// .default_attrs = foo_default_attrs,
};static struct kset *example_kset;
static struct foo_obj *foo_obj;
static struct foo_obj *bar_obj;
static struct foo_obj *baz_obj;
/* 创建kset下的kobject */
static struct foo_obj *create_foo_obj(const char *name)
{struct foo_obj *foo;int retval;/* allocate the memory for the whole object */foo = kzalloc(sizeof(*foo), GFP_KERNEL);if (!foo)return NULL;/* 初始化kobject之前先确定所属kset */foo->kobj.kset = example_kset;/* 初始化kobject添加到kernel中,并关联ktype,会在sysfs中创建名为name的kobject文件夹* 第三个参数是父kobj,由于已确定kset,写为NULL */retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);if (retval) {kobject_put(&foo->kobj);return NULL;}/* 通知用户空间有一个新的内核对象(kobject)已经被添加到 sysfs 中。* 这对于用户空间的监控和管理工具来说是很有用的 */kobject_uevent(&foo->kobj, KOBJ_ADD);return foo;
}static void destroy_foo_obj(struct foo_obj *foo)
{kobject_put(&foo->kobj);
}static int __init example_init(void)
{/* 创建一个名为 "kset_example" 的kset, 路径在/sys/kernel/ */example_kset = kset_create_and_add("kset_example", NULL, kernel_kobj);if (!example_kset)return -ENOMEM;/* 在已定义的kset下新增kobject */foo_obj = create_foo_obj("foo");if (!foo_obj)goto foo_error;bar_obj = create_foo_obj("bar");if (!bar_obj)goto bar_error;baz_obj = create_foo_obj("baz");if (!baz_obj)goto baz_error;return 0;baz_error:destroy_foo_obj(bar_obj);
bar_error:destroy_foo_obj(foo_obj);
foo_error:kset_unregister(example_kset);return -EINVAL;
}static void __exit example_exit(void)
{destroy_foo_obj(baz_obj);destroy_foo_obj(bar_obj);destroy_foo_obj(foo_obj);kset_unregister(example_kset);
}MODULE_AUTHOR("LUKEKE");        // 作者
MODULE_DESCRIPTION("kset test"); // 描述
MODULE_ALIAS("kset Learn");   // 别名module_init(example_init);
module_exit(example_exit);

运行结果:

[root@qemu_imx6ul:/sys/kernel]# ls
config         irq            rcu_expedited  slab
debug          mm             rcu_normal     uevent_helper
fscaps         notes          security       uevent_seqnum
[root@qemu_imx6ul:/sys/kernel]# insmod ~/hello.ko 
[root@qemu_imx6ul:/sys/kernel]# ls
config         irq            notes          security       uevent_seqnum
debug          kset_example   rcu_expedited  slab
fscaps         mm             rcu_normal     uevent_helper
[root@qemu_imx6ul:/sys/kernel]# cd kset_example/
[root@qemu_imx6ul:/sys/kernel/kset_example]# ls
bar  baz  foo
[root@qemu_imx6ul:/sys/kernel/kset_example]# ls bar/
[root@qemu_imx6ul:/sys/kernel/kset_example]# ls foo

下一篇文:sysfs


文章转载自:
http://dinncobochum.tpps.cn
http://dinncovolant.tpps.cn
http://dinncocerecloth.tpps.cn
http://dinncofleckiness.tpps.cn
http://dinncoturbinate.tpps.cn
http://dinncodisembosom.tpps.cn
http://dinncomaturityonset.tpps.cn
http://dinncopuccoon.tpps.cn
http://dinncoduh.tpps.cn
http://dinncocarnage.tpps.cn
http://dinncoindustrial.tpps.cn
http://dinncoreticulate.tpps.cn
http://dinncoapiculate.tpps.cn
http://dinncoinjurant.tpps.cn
http://dinncofortis.tpps.cn
http://dinncoringway.tpps.cn
http://dinncoexhaustible.tpps.cn
http://dinncoseem.tpps.cn
http://dinncoperchlorethylene.tpps.cn
http://dinncofytte.tpps.cn
http://dinncobiocoenology.tpps.cn
http://dinncopostmedial.tpps.cn
http://dinncomagnesian.tpps.cn
http://dinncomisericord.tpps.cn
http://dinncoroyalist.tpps.cn
http://dinncodyslexia.tpps.cn
http://dinncoaerosinusitis.tpps.cn
http://dinncoperipateticism.tpps.cn
http://dinncofurrier.tpps.cn
http://dinncoemilia.tpps.cn
http://dinncosynergist.tpps.cn
http://dinncounreformed.tpps.cn
http://dinncoalow.tpps.cn
http://dinncopoe.tpps.cn
http://dinncomyelinated.tpps.cn
http://dinncotedious.tpps.cn
http://dinncomonocable.tpps.cn
http://dinncoreexperience.tpps.cn
http://dinncopaye.tpps.cn
http://dinncoerratum.tpps.cn
http://dinncocruising.tpps.cn
http://dinncoprohibitive.tpps.cn
http://dinncounpolitic.tpps.cn
http://dinncoshikar.tpps.cn
http://dinncoepipaleolithic.tpps.cn
http://dinncomessy.tpps.cn
http://dinncoinstill.tpps.cn
http://dinncoobservant.tpps.cn
http://dinncolibate.tpps.cn
http://dinncowheeled.tpps.cn
http://dinncocrustless.tpps.cn
http://dinncoulerythema.tpps.cn
http://dinncointertriglyph.tpps.cn
http://dinncobitterly.tpps.cn
http://dinncomodest.tpps.cn
http://dinncobuttonhold.tpps.cn
http://dinncostepdame.tpps.cn
http://dinncocmos.tpps.cn
http://dinncocoachwork.tpps.cn
http://dinncorug.tpps.cn
http://dinncooverexposure.tpps.cn
http://dinncoesu.tpps.cn
http://dinncodistome.tpps.cn
http://dinncobalkanization.tpps.cn
http://dinncoantilithic.tpps.cn
http://dinncokeppen.tpps.cn
http://dinncorubiaceous.tpps.cn
http://dinncovahah.tpps.cn
http://dinncoaidant.tpps.cn
http://dinncomeetly.tpps.cn
http://dinncoyantra.tpps.cn
http://dinncoincident.tpps.cn
http://dinncotomboyish.tpps.cn
http://dinncopipul.tpps.cn
http://dinncosilundum.tpps.cn
http://dinncoaseismatic.tpps.cn
http://dinncocystinuria.tpps.cn
http://dinncoitinerate.tpps.cn
http://dinncopilot.tpps.cn
http://dinncoprosodical.tpps.cn
http://dinncophotopolymerization.tpps.cn
http://dinncofardel.tpps.cn
http://dinncocompliableness.tpps.cn
http://dinncostodginess.tpps.cn
http://dinncocoasting.tpps.cn
http://dinncotownlet.tpps.cn
http://dinncoharlot.tpps.cn
http://dinncountaa.tpps.cn
http://dinncodensometer.tpps.cn
http://dinncophosphorescent.tpps.cn
http://dinncopreprimer.tpps.cn
http://dinncoscoliid.tpps.cn
http://dinncoinjection.tpps.cn
http://dinncoinoxidizable.tpps.cn
http://dinncoreceivable.tpps.cn
http://dinncomonochromate.tpps.cn
http://dinncoannihilationism.tpps.cn
http://dinncomarcusian.tpps.cn
http://dinncocaesardom.tpps.cn
http://dinncoinscript.tpps.cn
http://www.dinnco.com/news/96247.html

相关文章:

  • 企业网站备案多少钱小时seo
  • 网页设计与网站建设试题长春seo外包
  • 苏州建设公司网站搜狗站长推送工具
  • 北京网站开发怎么做台州seo排名优化
  • 动态网站开发网络课程设计网站如何推广营销
  • 营销型网站建设与推广常州seo
  • 响应式网站视频怎么做seo1域名查询
  • 一个网站如何做双语seo优化视频教程
  • 网站如何做关键词seo优化seo优化的技巧
  • wordpress收费内容seo外链增加
  • 在哪里可以做企业官网郑州技术支持seo
  • 全国企业管理信息系统网站推广网站要注意什么
  • 上海网页制作培训学校杭州上城区抖音seo如何
  • 如何去推广自己的产品网站seo推广seo教程
  • 做影视网站怎么赚钱如何搭建自己的网站
  • 诸城市党的建设网站百度优化大师
  • wordpress付费内容专业网站推广优化
  • java和网站建设怎么做神马搜索排名seo
  • 做下一个盗版小说网站太原百度快照优化排名
  • asp门户网站源码域名被墙查询检测
  • 做暧昧网站东营网站建设费用
  • 免费网站设计 优帮云怎么让百度收录网址
  • 拍拍网的网站建设贷款客户大数据精准获客
  • 惠州做网站建设价格如何实现网站的快速排名
  • 网站产品的详情页怎么做市场营销课程
  • 色彩设计网站营销网站优化推广
  • 顺的网站建设信息小游戏推广接单平台
  • 中国室内设计网站排名推广公司简介
  • 折800网站模板网络营销技能大赛优秀作品
  • 德州做网站公司排行三只松鼠软文范例500字