Deleted Added
sdiff udiff text old ( 11793:ef606668d247 ) new ( 12164:6a4fd7d604b1 )
full compact
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 27 unchanged lines hidden (view full) ---

36
37#endif
38
39#include "base/pollevent.hh"
40
41#include <fcntl.h>
42#include <unistd.h>
43
44#include <csignal>
45
46#include "base/misc.hh"
47#include "base/types.hh"
48#include "sim/async.hh"
49#include "sim/core.hh"
50#include "sim/eventq.hh"
51#include "sim/serialize.hh"
52

--- 142 unchanged lines hidden (view full) ---

195 if (revents) {
196 events[i]->process(revents);
197 if (--ret <= 0)
198 break;
199 }
200 }
201}
202
203void
204PollQueue::setupAsyncIO(int fd, bool set)
205{
206 int flags = fcntl(fd, F_GETFL);
207 if (flags == -1)
208 panic("Could not set up async IO");
209
210 if (set)
211 flags |= FASYNC;
212 else
213 flags &= ~(FASYNC);
214
215 if (set) {
216 if (fcntl(fd, F_SETOWN, getpid()) == -1)
217 panic("Could not set up async IO");
218 }
219
220 if (fcntl(fd, F_SETFL, flags) == -1)
221 panic("Could not set up async IO");
222
223 // The file descriptor might already have events pending. We won't
224 // see them if they occurred before we set the FASYNC
225 // flag. Simulate a SIGIO to ensure that the FD will be polled in
226 // next iteration of the simulation loop. We could just poll it,
227 // but this is much simpler.
228 if (set) {
229 async_event = true;
230 async_io = true;
231 /* Wake up some event queue to handle event */
232 getEventQueue(0)->wakeup();
233 }
234}