Slide sem ttulo - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Slide sem ttulo

Description:

221 if (ipcperms(&msq- q_perm, msgflg)) 222 ret = -EACCES; 223 else { 224 int qid = msg_buildid(id, ... 339 * We prepend the allocation with the rcu struct, and ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 19
Provided by: fukuhara
Category:
Tags: prepend | sem | ttulo

less

Transcript and Presenter's Notes

Title: Slide sem ttulo


1
Criação da Fila de Mensagens
202 asmlinkage long sys_msgget (key_t key, int
msgflg) 203 204 int id, ret
-EPERM 205 struct msg_queue msq 206
207 down(msg_ids.sem) 208
if (key IPC_PRIVATE) 209 ret
newque(key, msgflg) 210 else if ((id
ipc_findkey(msg_ids, key)) -1) / key not
used / 211 if (!(msgflg
IPC_CREAT)) 212 ret
-ENOENT 213 else 214
ret newque(key, msgflg) 215
else if (msgflg IPC_CREAT msgflg
IPC_EXCL) 216 ret
-EEXIST 217 else 218
msq msg_lock(id) 219
if(msqNULL) 220
BUG() 221 if (ipcperms(msq-gtq_pe
rm, msgflg)) 222 ret
-EACCES 223 else 224
int qid msg_buildid(id,
msq-gtq_perm.seq) 225 ret
security_msg_queue_associate(msq, msgflg) 226
if (!ret) 227
ret qid 228
229 msg_unlock(msq) 230
231 up(msg_ids.sem) 232
return ret 233
2
88 static int newque (key_t key, int msgflg) 89
90 int id 91 int retval 92
struct msg_queue msq 93 94
msq ipc_rcu_alloc(sizeof(msq)) 95
if (!msq) 96 return -ENOMEM
3
335 void ipc_rcu_alloc(int size) 336 337
void out 338 / 339 We
prepend the allocation with the rcu struct,
and 340 workqueue if necessary (for
vmalloc). 341 / 342 if
(rcu_use_vmalloc(size)) 343 out
vmalloc(HDRLEN_VMALLOC size) 344
if (out) 345 out
HDRLEN_VMALLOC 346
container_of(out, struct ipc_rcu_hdr,
data)-gtis_vmalloc 1 347
container_of(out, struct ipc_rcu_hdr,
data)-gtrefcount 1 348 349
else 350 out
kmalloc(HDRLEN_KMALLOC size, GFP_KERNEL) 351
if (out) 352
out HDRLEN_KMALLOC 353
container_of(out, struct ipc_rcu_hdr,
data)-gtis_vmalloc 0 354
container_of(out, struct ipc_rcu_hdr,
data)-gtrefcount 1 355 356
357 358 return out 359
4
Kmalloc x Vmalloc kmalloc allocates physically
contiguous memory, memory which pages are laid
consecutively in physical RAM. vmalloc allocates
memory which is contiguous in kernel virtual
memory space (that means pages allocated that way
are not contiguous in RAM, but the kernel sees
them as one block).
5
Msgsend
  • asmlinkage long sys_msgsnd (
  • int msqid, // id
    da fila
  • struct msgbuf __user msgp, // buffer de msg
  • size_t msgsz, //tamanho
    da msg
  • int msgflg //flag de controle
  • )

6
  • struct msg_msg msg
  • struct list_head m_list / aponta para a
    cabeca da lista/
  • long m_type / tipo da
    mensagem/
  • int m_ts /tamanho do
    texto da mensagem /
  • struct msg_msgseg next /aponta para a proxima
    mensagem/
  • void security /aponta pra a
    estrutura de segunca/

7
  • struct msg_queue msq
  • struct list_head q_messages / é uma lista
    duplamente encadeada circular das mensagens da
    fila./
  • struct list_head q_receivers /é uma lista dos
    processos que recebem mensagens. /
  • struct list_head q_senders /é uma lista dos
    processos que enviam mensagens. /
  • time_t q_stime / last msgsnd time /
  • time_t q_rtime / last msgrcv time /
  • time_t q_ctime / last change time /
  • unsigned long q_cbytes / current number of
    bytes on queue /
  • unsigned long q_qnum / number of messages in
    queue /
  • unsigned long q_qbytes / max number of bytes on
    queue /

8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
Msgrcv
  • asmlinkage long sys_msgrcv (
  • int msqid, //id da fila
  • struct msgbuf __user msgp, // buffer de msg
  • size_t msgsz, //tamanho da msg
  • long msgtyp, //tipo msg
  • int msgflg // flag de controle
  • )

13
(No Transcript)
14
Convert_Mode
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com