由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 关于process and threads的问题
相关主题
why do we need to map user threads to kernel threads?C++一个类中多个thread的问题
多线程编程前景如何?面试问题一问 (转载)
c++下如何实现多线程?pthread and C++
写thread safe程序现在也是程序员必须要掌握的了吧一般thread-safe access
One OS scheduling question (转载)有专门介绍multithreading编程的书吗
哪位同修能帮我测试一下How to use multi-core to speed Python program
问题一枚多线程 编程,process 和 thread 的一些问题。
Windows Thread API请问有没有介绍thread pool的资料?
相关话题的讨论汇总
话题: user话题: exponent话题: process话题: cube话题: factorial
进入Programming版参与讨论
1 (共1页)
E********M
发帖数: 1372
1
请问具体怎么生成一个process, 然后这个process负责display 目录 (console 目录
就行了) 然后在这个process里创建3-4个threads ,每个thread 都负责去做一些
简单的公式计算呢呢?或者说,我怎么在process里用这些threads? 一下从data
structure的颗跳到system..有点摸不着边。。什么api 的都不懂。。。眼看作业今天
就要due 了。。
Write a program in C++ for a server (called math solver) which solves three
math problems: factorial (i.e. n!), exponent with base 2 (i.e. 2n), and cube
(i.e. n3). The server should be implemented as a process and the three
problems are implemented in three threads.
The server process is responsible for posting a menu of choices for the
user to select. Once a choice is made, the server asks the user for a
nonnegative integer (including 0). The server then creates the corresponding
thread and passes the integer to it to solve the problem. The program
continues until the user stops it.
The following shows a scenario of running the program, where user’s
inputs are represented in boldface.
>p2smith {an executable program}
program starts running .....
which problem do you like to solve?
1 = factorial
2 = exponent with base 2
3 = cube
4 = exit
2 <---user input
please enter a nonnegative integer: 5 <---user input
the answer is: 32 {from the exponent thread}
which problem do you like to solve?
1 = factorial
2 = exponent with base 2
3 = cube
4 = exit
3 <---user input
please enter a nonnegative integer: 4 <---user input
the answer is: 64 {from the cube thread}
which problem do you like to solve?
1 = factorial
2 = exponent with base 2
3 = cube
4 = exit
4 <---user input
1 (共1页)
进入Programming版参与讨论
相关主题
请问有没有介绍thread pool的资料?One OS scheduling question (转载)
A helloworld OpenMP question?哪位同修能帮我测试一下
C++ and threading interview questions问题一枚
推荐一下C++多线程的书吧Windows Thread API
why do we need to map user threads to kernel threads?C++一个类中多个thread的问题
多线程编程前景如何?面试问题一问 (转载)
c++下如何实现多线程?pthread and C++
写thread safe程序现在也是程序员必须要掌握的了吧一般thread-safe access
相关话题的讨论汇总
话题: user话题: exponent话题: process话题: cube话题: factorial