如何在c中使用struct
我试图编写一个程序来生成斐波那契数,这样父进程将调用 fork,子进程将在共享内存中写入序列,父进程将从中读取序列并显示。我知道如何创建共享内存,但我不知道如何链接结构数组和共享内存,以便父级在子级完成后显示值
I was trying to write a program to generate fibonacci such that parent process will call fork and child process will write sequences in shared memory fromwhere parent process will read the sequence and display .I know how to create shared memory but I donot know how to link struct array and shared memory so that parent display the value after child complete
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 mmap 在 fork 后在父进程和子进程之间共享一些内存。很难看出你到底想做什么或为什么要尝试这样做(假设这是某种练习),所以详细说明是个好主意。
You could use mmap to share some memory between a parent a child process after a fork. It's hard to see what you're exactly trying to do or why you're trying to do it (assuming it's some sort of exercise) so it'd be a good idea to elaborate.