* Also add the creating thread to an IORequest and let child requests

inherit it.
* IOScheduler::ScheduleRequest() uses the request's thread and team now
  instead of the current one. Otherwise for requests processed
  iteratively this would always be the I/O scheduler's notifier thread.
* Also get the thread's I/O priority now. It's still ignored later,
  though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27248 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-08-31 00:43:46 +00:00
parent 3b3e3805f8
commit 841b6cd749
3 changed files with 16 additions and 6 deletions

View File

@ -144,6 +144,7 @@ IOScheduler::Init(const char* name)
IORequestOwner& owner = fAllocatedRequestOwners[i]; IORequestOwner& owner = fAllocatedRequestOwners[i];
owner.team = -1; owner.team = -1;
owner.thread = -1; owner.thread = -1;
owner.priority = B_IDLE_PRIORITY;
fUnusedRequestOwners.Add(&owner); fUnusedRequestOwners.Add(&owner);
} }
@ -217,8 +218,7 @@ IOScheduler::ScheduleRequest(IORequest* request)
MutexLocker locker(fLock); MutexLocker locker(fLock);
struct thread* thread = thread_get_current_thread(); IORequestOwner* owner = _GetRequestOwner(request->Team(), request->Thread(),
IORequestOwner* owner = _GetRequestOwner(thread->team->id, thread->id,
true); true);
if (owner == NULL) { if (owner == NULL) {
panic("IOScheduler: Out of request owners!\n"); panic("IOScheduler: Out of request owners!\n");
@ -231,8 +231,10 @@ IOScheduler::ScheduleRequest(IORequest* request)
bool wasActive = owner->IsActive(); bool wasActive = owner->IsActive();
request->SetOwner(owner); request->SetOwner(owner);
owner->requests.Add(request); owner->requests.Add(request);
owner->priority = thread->priority;
// TODO: Use the I/O priority instead! int32 priority = thread_get_io_priority(request->Thread());
if (priority >= 0)
owner->priority = priority;
//dprintf(" request %p -> owner %p (thread %ld, active %d)\n", request, owner, owner->thread, wasActive); //dprintf(" request %p -> owner %p (thread %ld, active %d)\n", request, owner, owner->thread, wasActive);
if (!wasActive) if (!wasActive)
@ -753,6 +755,7 @@ IOScheduler::_GetRequestOwner(team_id team, thread_id thread, bool allocate)
fRequestOwners->RemoveUnchecked(owner); fRequestOwners->RemoveUnchecked(owner);
owner->team = team; owner->team = team;
owner->thread = thread; owner->thread = thread;
owner->priority = B_IDLE_PRIORITY;
fRequestOwners->InsertUnchecked(owner); fRequestOwners->InsertUnchecked(owner);
break; break;
} }

View File

@ -12,7 +12,7 @@
#include <debug.h> #include <debug.h>
#include <heap.h> #include <heap.h>
#include <kernel.h> #include <kernel.h>
#include <team.h> #include <thread.h>
#include <util/AutoLock.h> #include <util/AutoLock.h>
#include <vm.h> #include <vm.h>
@ -640,7 +640,9 @@ IORequest::Init(off_t offset, size_t firstVecOffset, const iovec* vecs,
fRelativeParentOffset = 0; fRelativeParentOffset = 0;
fTransferSize = 0; fTransferSize = 0;
fFlags = flags; fFlags = flags;
fTeam = team_get_current_team_id(); struct thread* thread = thread_get_current_thread();
fTeam = thread->team->id;
fThread = thread->id;
fIsWrite = write; fIsWrite = write;
fPartialTransfer = 0; fPartialTransfer = 0;
@ -703,6 +705,8 @@ IORequest::CreateSubRequest(off_t parentOffset, off_t offset, size_t length,
} }
subRequest->fRelativeParentOffset = parentOffset - fOffset; subRequest->fRelativeParentOffset = parentOffset - fOffset;
subRequest->fTeam = fTeam;
subRequest->fThread = fThread;
_subRequest = subRequest; _subRequest = subRequest;
subRequest->SetParent(this); subRequest->SetParent(this);
@ -1183,6 +1187,7 @@ IORequest::Dump() const
kprintf(" pending children: %ld\n", fPendingChildren); kprintf(" pending children: %ld\n", fPendingChildren);
kprintf(" flags: %#lx\n", fFlags); kprintf(" flags: %#lx\n", fFlags);
kprintf(" team: %ld\n", fTeam); kprintf(" team: %ld\n", fTeam);
kprintf(" thread: %ld\n", fThread);
kprintf(" r/w: %s\n", fIsWrite ? "write" : "read"); kprintf(" r/w: %s\n", fIsWrite ? "write" : "read");
kprintf(" partial transfer: %s\n", fPartialTransfer ? "yes" : "no"); kprintf(" partial transfer: %s\n", fPartialTransfer ? "yes" : "no");
kprintf(" finished cvar: %p\n", &fFinishedCondition); kprintf(" finished cvar: %p\n", &fFinishedCondition);

View File

@ -267,6 +267,7 @@ struct IORequest : IORequestChunk, DoublyLinkedListLinkImpl<IORequest> {
bool IsWrite() const { return fIsWrite; } bool IsWrite() const { return fIsWrite; }
bool IsRead() const { return !fIsWrite; } bool IsRead() const { return !fIsWrite; }
team_id Team() const { return fTeam; } team_id Team() const { return fTeam; }
thread_id Thread() const { return fThread; }
uint32 Flags() const { return fFlags; } uint32 Flags() const { return fFlags; }
IOBuffer* Buffer() const { return fBuffer; } IOBuffer* Buffer() const { return fBuffer; }
@ -321,6 +322,7 @@ private:
int32 fPendingChildren; int32 fPendingChildren;
uint32 fFlags; uint32 fFlags;
team_id fTeam; team_id fTeam;
thread_id fThread;
bool fIsWrite; bool fIsWrite;
bool fPartialTransfer; bool fPartialTransfer;