由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这题怎么做?
相关主题
这题怎么做?Simulation&Visualization engineer
问一道题问个multi threading code 题,同时请问高手mutil threading 编程有什么好书,网站和教程推荐?
leetcode上的一题。一道关于SMP and threading 题目
F家面经career cup 如何测context switch花费时间?
请教两道面试题two functons and two threads
Blackrock onsite求教神码是 Unix/Posix programming
这道设计题怎么做?一道多线程的面试题
[新鲜面经]intern NI(National Instruments) FPGA compiler 组c++ thread 求助 (转载)
相关话题的讨论汇总
话题: thread话题: producer话题: usb话题: printtask话题: consumer
进入JobHunting版参与讨论
1 (共1页)
b**********5
发帖数: 7881
1
You are writing a simulation for a print server. This print
server can accept jobs from 3 places - network, USB, or operator. It can
dispatch only one job at a time. Each input job should contain an integer t
which is the time in seconds it will take to process the job. Write a multi-
threaded program to simulate the server and provide some simulated load with
jobs. Think, of some interesting statistics your program should emit and
code them in.
b**********5
发帖数: 7881
2
Up
n*******s
发帖数: 17267
3
招个新人做
e********2
发帖数: 495
4
不会。

t
multi-
with

【在 b**********5 的大作中提到】
: You are writing a simulation for a print server. This print
: server can accept jobs from 3 places - network, USB, or operator. It can
: dispatch only one job at a time. Each input job should contain an integer t
: which is the time in seconds it will take to process the job. Write a multi-
: threaded program to simulate the server and provide some simulated load with
: jobs. Think, of some interesting statistics your program should emit and
: code them in.

b**********5
发帖数: 7881
5
up, 一家的online test。。。 除了这题, 他妈的还有其他三道题。。。 要45分钟
做完。。
g*****g
发帖数: 34805
6
Use a blocking queue, this is a typical producer/consumer multi-thread
question.

t
multi-
with

【在 b**********5 的大作中提到】
: You are writing a simulation for a print server. This print
: server can accept jobs from 3 places - network, USB, or operator. It can
: dispatch only one job at a time. Each input job should contain an integer t
: which is the time in seconds it will take to process the job. Write a multi-
: threaded program to simulate the server and provide some simulated load with
: jobs. Think, of some interesting statistics your program should emit and
: code them in.

b**********5
发帖数: 7881
7
I know u need a queue, but how do u write USB...sockets and shit? and then
should I use a registed callback to do statistics like actual time used to
process tasks?


【在 g*****g 的大作中提到】
: Use a blocking queue, this is a typical producer/consumer multi-thread
: question.
:
: t
: multi-
: with

g*****g
发帖数: 34805
8
No, it's called simulation, all you need is label the producers as "USB"
blah blah and print out as such. You register the timestamp when the job is
produced and calculate the diff when the job is consumed, it's exactly the
basic P/C question.

【在 b**********5 的大作中提到】
: I know u need a queue, but how do u write USB...sockets and shit? and then
: should I use a registed callback to do statistics like actual time used to
: process tasks?
:

g*****g
发帖数: 34805
9
Executors.newFixedThreadPool(1);
class PrintTask extends Callable {
public PrintTask(DeviceEnum device, int printTime);
}
record current timestamp and use finish time to come up with statistics is
enough.
Not rocket science.
b**********5
发帖数: 7881
10
are you saying the following is enough??!!!
public class Printer {
main () {
BlocingQueue q...
Thread USBThread = new Thread (new Producer(q));
Thread USB1Thread = new Thread (new Producer(q));

Thread consumerThread = new Thread (new Consumer(q));

thread.starts();
thread.start(); ...
}
}
then the USBthread just add dummy tasks to the queue??! I just create a
dummy class Task? I don't need no bytestreams or shit like that?!
and in the consumer thread, just take one by one?

【在 b**********5 的大作中提到】
: I know u need a queue, but how do u write USB...sockets and shit? and then
: should I use a registed callback to do statistics like actual time used to
: process tasks?
:

相关主题
Blackrock onsiteSimulation&Visualization engineer
这道设计题怎么做?问个multi threading code 题,同时请问高手mutil threading 编程有什么好书,网站和教程推荐?
[新鲜面经]intern NI(National Instruments) FPGA compiler 组一道关于SMP and threading 题目
进入JobHunting版参与讨论
b**********5
发帖数: 7881
11
got it. thanks. so just a simulation with one consumer and producer thread
.

【在 g*****g 的大作中提到】
: Executors.newFixedThreadPool(1);
: class PrintTask extends Callable {
: public PrintTask(DeviceEnum device, int printTime);
: }
: record current timestamp and use finish time to come up with statistics is
: enough.
: Not rocket science.

g*****g
发帖数: 34805
12
No, it's one consumer and any number of producers.

thread

【在 b**********5 的大作中提到】
: got it. thanks. so just a simulation with one consumer and producer thread
: .

b**********5
发帖数: 7881
13
? So i am assuming it will be a queue of PrintTask u defined above.
So are u saying i should start 3 producer threads for 3 devices? But if u
already include device enum in the printtask, then why do u need 3 different
threads for each?

【在 g*****g 的大作中提到】
: No, it's one consumer and any number of producers.
:
: thread

g*****g
发帖数: 34805
14
You don't need to start any producer thread. threadpool is about consumer.
An enum is enough to mark the producer.

different

【在 b**********5 的大作中提到】
: ? So i am assuming it will be a queue of PrintTask u defined above.
: So are u saying i should start 3 producer threads for 3 devices? But if u
: already include device enum in the printtask, then why do u need 3 different
: threads for each?

b**********5
发帖数: 7881
15
now i am back to square one... if u not gonna have any producer thread, then
how is the queue of PrintTasks getting added?

【在 g*****g 的大作中提到】
: You don't need to start any producer thread. threadpool is about consumer.
: An enum is enough to mark the producer.
:
: different

d**p
发帖数: 510
16
Operator, USB and network should take care of producing tasks. Printer can
provide a function to accept these tasks and insert into queue.
g*****g
发帖数: 34805
17
For simulation,you just need to demonstrate the ability submit each task
asynchronously. That's why each task is a callable future.
e.g.
Future f = threadpool.submit(new PrintTask(USB, 10));

different

【在 b**********5 的大作中提到】
: ? So i am assuming it will be a queue of PrintTask u defined above.
: So are u saying i should start 3 producer threads for 3 devices? But if u
: already include device enum in the printtask, then why do u need 3 different
: threads for each?

1 (共1页)
进入JobHunting版参与讨论
相关主题
c++ thread 求助 (转载)请教两道面试题
请教三个多线程(multi-threading)题目Blackrock onsite
看来TANGO 比 FLAGT 要求都高啊!这道设计题怎么做?
[合集] 2006年底石油公司面试 (经验 游记) zz[新鲜面经]intern NI(National Instruments) FPGA compiler 组
这题怎么做?Simulation&Visualization engineer
问一道题问个multi threading code 题,同时请问高手mutil threading 编程有什么好书,网站和教程推荐?
leetcode上的一题。一道关于SMP and threading 题目
F家面经career cup 如何测context switch花费时间?
相关话题的讨论汇总
话题: thread话题: producer话题: usb话题: printtask话题: consumer