Trang Chủ | Diễn Đàn | Thành Viên (Đăng Ký) | Tìm Kiếm | Tutorial Room
Windows Programming - cần giúp đỡ về process affinity mark
Hỏi đáp, trao đổi chung về lập trình trên môi trường Windows và WinAPI. Các câu hỏi về các ngôn ngữ cụ thể xin hãy gởi vào các box con tương ứng!
First page Previous page  (Page 1 )   1   Next page Last page
cần giúp đỡ về process affinity mark
Member
Member since
20:04 03-07-2006
Posts: 2
Fantasy Points: 7
question Posted at 04:27 02-06-2009 Move Move Topic   Pin/Unpin Pin Topic   Lock Lock Topic
Hi các bác.
Hiện em đang có một bài tập về Process như sau:
Moi truong OS :WinXP, Core 2 Duo, MFC

Chuong trinh chay (a.exe) cua em la mot process, khi chuong trinh a.exe cua em chay len thi set affinity cho no la 1 (tuc la process nay va tat ca cac thread thuoc process nay chi dung con CPU thu1 thoi)..nhung bay h trong chuong trinh cua em muon tao mot thread ma dung CPU thu 2 thi em phai lam the nao?

Cach lam hien tai cua em nhu sau thi ko duoc

a.exe oninit()
{
// khi init ung dung thi set no dung CPU 1
SetProcessAffinityMask (GetCurrentProcess(),1L);
}

khi click vao button [ABC] cua ung dung a.exe thi tao mot thread
{
HANDLE abc = CreateThread(....);
// set thread nay chay tren CPU thu 2
SetThreadAffinityMask(abc,2L);
// ham nay tra ve loivi hien tai main process dang set la CPU 1
}

Xin bao nao da lam qua ve van de nay xin chi giao cho em voi?
Thanks so murch.
This post has been edited 1 time(s). Last edited by Admin on 04:49 02-06-2009.
Reply Reply   Quote Quote   Edit Edit   Delete Delete   Report Report
This post has been viewed 1,577 time(s). 1 direct repli(es) and 0 indirect repli(es).
Title Poster
question cần giúp đỡ về process affinity mark
 
answer Re: cần giúp đỡ về process affinity mark
freeman
Re: cần giúp đỡ về process affinity mark
Member
Member since
19:48 04-06-2005
Posts: 328
Fantasy Points: 2,594
answer Posted at 00:35 10-06-2009
Reply to cần giúp đỡ về process affinity mark (ncsduong)
Đề nghị bạn sửa lại bài viết đầy đủ dấu nhé.
===

MSDN:
Remarks

A thread affinity mask is a bit vector in which each bit represents a logical processor that a thread is allowed to run on. A thread affinity mask must be a subset of the process affinity mask for the containing process of a thread. A thread can only run on the processors its process can run on. Therefore, the thread affinity mask cannot specify a 1 bit for a processor when the process affinity mask specifies a 0 bit for that processor.

Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.

If the new thread affinity mask does not specify the processor that is currently running the thread, the thread is rescheduled on one of the allowable processors.

(http://msdn.microsoft.com/en-us/library/ms686247(VS.85).aspx)

Hiểu nôm na là tiến trình cha được phép hoạt động trên nhân nào thì các phân luồng con của nó cũng chỉ hoạt động được trên nhân đó thôi.
___________________________
sorry for my bad En...
This post has been edited 1 time(s). Last edited by freeman on 00:36 10-06-2009.
Reply Reply   Quote Quote   Edit Edit   Delete Delete   Report Report
This post has been viewed 1,516 time(s). 0 direct repli(es) and 0 indirect repli(es).
First page Previous page  (Page 1 )   1   Next page Last page

Permissions: Create Topic: No  |  Reply Topic: No  |  Attach File: No  |  Make Poll: No

Vietnamese Keyboard: AUTO TELEX VNI VIQR VIQR* OFF

Go top || Print page ||

All logos, trademarks and graphics artwork in this site are property of their respective owners.
Opinions expressed in articles within this site are those of their owners and may not reflect the opinion of TXBB.

TXBB: Home - Disclaimer - Help - Contact
Copyright (C) 2000-2006 TXBB. All rights reserved.

TreXanh Bulletin Board v2.0 (Build: #332 Nov 21, 2006)

DEBUG INFORMATION
Execution 0.155s - SQL used 6s - Concurrent process(es) 0