command - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

command

Description:

Title: command Author: Microsoft Corporation Last modified by: Jaechun No Created Date: 10/5/2006 4:04:58 AM Document presentation format: (4:3) – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 24
Provided by: Microso146
Category:
Tags: command | kernel | linux

less

Transcript and Presenter's Notes

Title: command


1
  • ?????
  • int shmget(key_t key, size_t size, int
    permflags)
  • - size ??? ??? ??? ??? ?? ??? ??? ??? ??
  • - IPC_CREAT IPC_EXCL
  • int shmat(int shmid, const void daddr, int
    shmflags)
  • daddr
  • NULL ???? ?? ??
  • shmflags
  • SHM_RDONLY, SHM_RND

2
  • ?????
  • int shmctl (int shmid, int command, struct
    shmid_ds shmstat)
  • -command IPC_STAT, IPC_SET, IPC_RMID
  • (??) test1.c (p288)

3
????? (??) shmcpy? ?? - 3?? ?? ????? ???? ??
0? 063, 1? 64127, 2? 128191? ?????? ?? ?????
??. ?? ???? ?? ? P, V? ?????. (??) ? ?????
message queue? ??? - ?? 0? 063? ???? ??? ??? ??
???? ?? - ?? 1? 64127? ???? ??? ??? ?? ????
?? - ?? 2? 128191? ???? ??? ??? ?? ???? ??
4
?? ???
?? ?? ??? ??
?? 2.4 Loadable module support ----- gt Enable loadable module support Set version information on all module symbols Kernel module loader
?? 2.6 Loadable module support ----- gt Enable loadable module support module unloading Forced module unloading Module versioning support (EXPERIMENTAL) Automatic kernel module loading
5
???? ??(1)
6
???? ??(2)
  • mknod ??
  • ???? ?? ??
  • mknod ???? ??? ?? ?
  • ? ?? ? ??
  • mknod /dev/devfile c 240 1

???? ???? ??
???? ???? ??
7
?? ????
  • insmod
  • ??? ??? ????.
  • rmmod
  • ??? ??? ??? ????.
  • lsmod
  • ??? ??? ??? ??? ????.

8
?? ?? ??(1)
  • ?? ?? ??
  • ?? ??? ??, ?? ??

?? 2.6
include ltlinux/init.hgt include ltlinux/module.hgt include ltlinux/kernel.hgt
?? 2.6
module_init(hello_init) module_exit(hello_exit)
9
?? ???? Makefile
obj-m test.o // ??? ??? ??
?? KDIR /lib/modules/(shell uname
-r)/build // ??? ?? ?? ?? PWD
(shell pwd) // ??? ??? ?? ???
?? default // ??? ????? ?? ??
(MAKE) -C (KDIR) SUBDIRS(PWD)
modules clean // ??? ??? ??? ??? ?
rm -rf .ko // ? ???.
rm -rf .mod. rm -rf ..cmd rm
-rf .o
10
?? ???? ???(1)
  • test.c

include ltlinux/init.hgt include
ltlinux/module.hgt include ltlinux/kernel.hgt static
int hello_init(void) printk("Hello,
world \n") return 0 static void
hello_exit(void) printk("Goodbye,
world\n") module_init(hello_init) module_exit
(hello_exit) MODULE_LICENSE("Dual BSD/GPL")
11
?? ???? ???(2)
  • Makefile

obj-m test.o KDIR
/lib/modules/(shell uname -r)/build PWD
(shell pwd) default (MAKE) -C
(KDIR) SUBDIRS(PWD) modules clean rm
-rf .ko rm -rf .mod. rm -rf
..cmd rm -rf .o
12
?? ???? ???(3)
13
?? ???? ???(4)
14
?? ???? ???(5)
15
???? ????
  • ?? ?? ???? ???? ???? ??
  • ??? ??? ??? ???? ?????
  • ???? ?? ??.
  • include ltasm/types.hgt? ??.
  • ?? ???? ????

App Kernel App Kernel
__s8 s8 ???? 8?? ??? __u8 u8 ???? 8?? ???
__s16 s16 ???? 16?? ??? __u16 u16 ???? 16?? ???
__s32 s32 ???? 32?? ??? __u32 u32 ???? 32?? ???
__s64 s64 ???? 64?? ??? __u64 u64 ???? 64?? ???
16
?? ??? ?? ??
kmalloc() kfree() ?? ??? ??? ???? ??? ???? ?????? ?? ?? ???? ??(?? ?? ?? ??).
vmalloc() vfree() ????? ???? ? ?? ?? ?? ?? ?? ? ??. ? ??? ??? ??? ? ?? ????(??? ???).
__get_free_pages() __free_pages() ? ???? ?? ??.
17
kmalloc(), kfree()-1
????? kmalloc(?? ?? ??, ??) kfree(?????) ??
??? ?? ??? 32 x PAGE_SIZE (????? 128KB) include
ltlinux/slab.hgt char buf buf kmalloc(1024,
GFP_KERNEL) if (buf ! NULL)
kfree(buf)
18
kmalloc(), kfree()-2
??? ?? ? ???? ?? (??? ???? ??? ??? ?? ??? ?????
??)
GFP_KERNEL ?? ??? ??? ?? ????? ????. ??? ?? ? ???? ?? ??? ? ??? ???. ?? ???? ??? ??????? ???? ? ??.
GFP_ATOMIC ??? ?? ??? ???? ??? ??? ????, ??? ?? NULL? ????. ????? ??? ??? ??? ??? ??? ??? ??? ?? ?? ? ??? ??.
GFP_DMA ??? ?? ???? ?? ?? ? ????. (DMA? ??? ? ???? ??.)
19
vmalloc(), vfree()
????? vmalloc(?? ?? ??) vfree(?????) include
ltlinux/vmalloc.hgt char buf buf
vmalloc(1024) if (buf ! NULL)
vfree(buf)
20
vmalloc(), vfree() ??
  • ?? ?? ???? ???? ??? ????? ???
  • ?????? ?? ?? ?? ??? ? ??.
  • ??? ??? ??? ???? ?? ????? ?? ???
  • ???? ??? kmalloc() ?? ??? ?? ???.
  • ?? ? ????? ??? ??? ? ? ?? ???
  • ???? ??? ?? ???? ??? ? ??.

21
__get_free_pages(), free_pages()
????? __get_free_pages(??, ??) free_pages(?????)
include ltlinux/mm.hgt //2.4 include
ltlinux/gfp.hgt //2.6 include ltasm/page.hgt
//get_order char buf buf
__get_free_pages(GFP_KERNEL, order) /
order0?? 1?? page, order3?? 3?? page /
MAX_ORDER? 11, ??? 5??? ?? ???? ?? ??
(32PAGE_SIZE) / if (buf ! NULL)
free_pages(buf, order)
22
(No Transcript)
23
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com