private void mountBattery(BaseHandleResource request) { if (this.kernelStorage.channelDevice.battery == 1) { return; } this.kernelStorage.channelDevice.battery = 1; int hndl = this.kernelStorage.handles.add(new Battery()); Resource response = new CreateHandleResponse(this.id, hndl, request.createdByProcess, HandleType.Battery); kernelStorage.resources.add(response); request.release(); }
public override void run() { switch (this.IC) { case 0: { bool hasResource = getAllResources(ResType.BaseHandleResource).Any(); if (this.resourceRequestor.RequestedResources.Count == 0) { this.resourceRequestor.request(ResType.BaseHandleResource, -1, !hasResource); } this.IC++; break; } case 1: { List <Resource> reqs = getAllResources(ResType.BaseHandleResource); this.lastid++; if (reqs.Count == 0) { this.IC = 0; break; } if (this.lastid >= reqs.Count) { this.lastid = 0; } BaseHandleResource req = reqs[this.lastid] as BaseHandleResource; this.last = req; switch (req.handleResourceType) { case HandleOperationType.CreateFileHandle: this.IC = 2; break; case HandleOperationType.Read: this.IC = 3; break; case HandleOperationType.Write: this.IC = 4; break; case HandleOperationType.Close: this.IC = 5; break; case HandleOperationType.Delete: this.IC = 6; break; case HandleOperationType.CreateBatteryHandle: this.IC = 7; break; case HandleOperationType.Seek: this.IC = 8; break; default: throw new NotImplementedException(); } //this.IC = 0; //if (this.kernelStorage.resources.Resources // .Where(res => res.assignedTo == this) // .Count() == 0 // ) this.IC = 0; break; } case 2: { createHandle(this.last as CreateHandleRequest); this.IC = 0; break; } case 3: { readHandle(this.last as ReadHandleRequest); this.IC = 0; break; } case 4: { writeHandle(this.last as WriteHandleRequest); this.IC = 0; break; } case 5: { closeHandle(this.last as HandleOperationRequest); this.IC = 0; break; } case 6: { deleteHandle(this.last as HandleOperationRequest); this.IC = 0; break; } case 7: { mountBattery(this.last); this.IC = 0; break; } case 8: { seekHandle(this.last as SetHandleSeekRequest); this.IC = 0; break; } } }