Выделение памяти для пространства пользователя от потока ядра

Вы путаете абстрактный стек, и аппаратные средства реализовали стек. Последний уже реализован.

5
задан Ciro Santilli 新疆改造中心法轮功六四事件 12 August 2017 в 01:45
поделиться

1 ответ

Don't attempt to allocate memory for userspace from the kernel - this is a huge violation of the kernel's abstraction layering. Instead, consider a few other options:

  • Have userspace ask how much space it needs. Userspace allocates, then grabs the memory from the kernel.
  • Have userspace mmap pages owned by your driver directly into its address space.
  • Set an upper bound on the amount of data needed. Just allocate that much.

It's hard to say more without knowing why this has to be atomic. Actually allocating memory's going to need to be interruptible anyway (or you're unlikely to succeed), so it's unlikely that going out of and back into the kernel is going to hurt much. In fact, any write to userspace memory must be interruptible, as there's the potential for page faults requiring IO.

11
ответ дан 13 December 2019 в 19:30
поделиться
Другие вопросы по тегам:

Похожие вопросы: