高分面试题目 用STL编写多线程有关问题
高分求助面试题目 用STL编写多线程问题
Description:
Write a command-line program BASE64.EXE that takes as input 3 variables: the input folder, the output folder, and the number of threads to use. Example:
BASE64 C:\B64\SOURCE C:\B64\DEST 2
This asks the program to read all the files from the C:\B64\SOURCE folder, convert them using base64 encoding, and write the results to the C:\B64\DEST folder. The program would use 2 threads to process 2 files at once. This allows the program to execute faster on multi-processor machines.
(In actual practice, the base64 conversion is not very computation-intensive, so the bottleneck is likely to be the input/output rather than CPU time, but for many algorithms this would be an important approach to follow.)
Framework/environment:
Please use the standard C++ library wherever possible, including the STL (Standard Template Library). The program
should run on Windows 9x, XP, Vista, etc.
You can use the Boost libraries as well, and/or WIN32 functions to create threads and mutexes, as well as for file
directory functions. Do not use MFC, .NET, or any other large frameworks.
Use object-oriented programming, and any common design patterns that might be appropriate. For example, the “thread pool pattern” is an ideal pattern to use to have the algorithm use a variable number of threads.
Notes:
– Ensure that your compiler is set to link to a multithreaded version of the library.
– The program does not need a GUI. Your compiler/linker must be set to make a command-line program.
– The best form of documentation is a clear class structure, and well chosen names.
– Please submit source code files, including tests, and any other files used.
– There are many descriptions of base64 encoding on the internet. e.g. see
http://users.aber.ac.uk/jjr6/material/base64/base64.pdf
Collaboration:
The team members should analyse the problem together and determine how to break up the work into component parts.
Description:
Write a command-line program BASE64.EXE that takes as input 3 variables: the input folder, the output folder, and the number of threads to use. Example:
BASE64 C:\B64\SOURCE C:\B64\DEST 2
This asks the program to read all the files from the C:\B64\SOURCE folder, convert them using base64 encoding, and write the results to the C:\B64\DEST folder. The program would use 2 threads to process 2 files at once. This allows the program to execute faster on multi-processor machines.
(In actual practice, the base64 conversion is not very computation-intensive, so the bottleneck is likely to be the input/output rather than CPU time, but for many algorithms this would be an important approach to follow.)
Framework/environment:
Please use the standard C++ library wherever possible, including the STL (Standard Template Library). The program
should run on Windows 9x, XP, Vista, etc.
You can use the Boost libraries as well, and/or WIN32 functions to create threads and mutexes, as well as for file
directory functions. Do not use MFC, .NET, or any other large frameworks.
Use object-oriented programming, and any common design patterns that might be appropriate. For example, the “thread pool pattern” is an ideal pattern to use to have the algorithm use a variable number of threads.
Notes:
– Ensure that your compiler is set to link to a multithreaded version of the library.
– The program does not need a GUI. Your compiler/linker must be set to make a command-line program.
– The best form of documentation is a clear class structure, and well chosen names.
– Please submit source code files, including tests, and any other files used.
– There are many descriptions of base64 encoding on the internet. e.g. see
http://users.aber.ac.uk/jjr6/material/base64/base64.pdf
Collaboration:
The team members should analyse the problem together and determine how to break up the work into component parts.