@ai-ecoverse/slicc-kernel 1.100.0 → 1.100.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.js CHANGED
@@ -3030,7 +3030,7 @@ async function runTagged(l, self, requested, tag) {
3030
3030
  }
3031
3031
  function processes(l, self) {
3032
3032
  const viewer = credOf(self);
3033
- return l.list(viewer).map(({ tid: _, cred = viewer, umask: _umask, ...entry }) => ({
3033
+ return l.list(viewer).map(({ tid: _, cred = viewer, umask: _umask, threads: _threads, ...entry }) => ({
3034
3034
  ...entry,
3035
3035
  rss: entry.memory,
3036
3036
  uid: cred.euid,
@@ -10572,6 +10572,13 @@ var ProcessClocks = class {
10572
10572
  running() {
10573
10573
  return this.enabled ? this.all().filter((c) => c.running()).length : 0;
10574
10574
  }
10575
+ states() {
10576
+ const state = (c) => c.running() ? "R" : "S";
10577
+ return [
10578
+ { tid: 1, state: state(this.main) },
10579
+ ...[...this.threads].map(([tid, c]) => ({ tid, state: state(c) }))
10580
+ ];
10581
+ }
10575
10582
  timed(clock, dispatch2) {
10576
10583
  const c = clock ?? this.main;
10577
10584
  const block = () => c.block();
@@ -11100,7 +11107,7 @@ var PATH_OPS = new Set(SYNC_FS_OPS);
11100
11107
  var EARLY_WHOLE_FILE = 64 * 1024;
11101
11108
 
11102
11109
  // src/version.ts
11103
- var KERNEL_VERSION = true ? "1.100.0" : "0.0.0-dev";
11110
+ var KERNEL_VERSION = true ? "1.100.1" : "0.0.0-dev";
11104
11111
  var OS_RELEASE = "6.0.0-slicc";
11105
11112
  function procVersion() {
11106
11113
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -11160,11 +11167,11 @@ function pages(bytes) {
11160
11167
  function ticks(ms) {
11161
11168
  return Math.max(0, Math.floor(ms * HZ / 1e3));
11162
11169
  }
11163
- function pidStat(info, boot) {
11170
+ function pidStat(info, boot, state = info.state) {
11164
11171
  const fields = [
11165
11172
  info.pid,
11166
11173
  `(${commOf(info)})`,
11167
- info.state,
11174
+ state,
11168
11175
  info.ppid,
11169
11176
  info.pgid,
11170
11177
  info.sid,
@@ -11202,8 +11209,19 @@ function pidStat(info, boot) {
11202
11209
  `;
11203
11210
  }
11204
11211
  var sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
11205
- var STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
11212
+ var STATES = {
11213
+ S: "S (sleeping)",
11214
+ T: "T (stopped)",
11215
+ Z: "Z (zombie)"
11216
+ };
11206
11217
  var tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
11218
+ function taskStat(info, tid, boot) {
11219
+ const thread = (info.threads ?? [{ tid: 1, state: info.state }]).find((t) => t.tid === tid);
11220
+ return thread && pidStat({ ...info, pid: tid }, boot, thread.state);
11221
+ }
11222
+ function taskIds(info) {
11223
+ return (info.threads ?? [{ tid: 1 }]).map((t) => t.tid);
11224
+ }
11207
11225
  function pidStatus(info) {
11208
11226
  const state = STATES[info.state];
11209
11227
  const c = info.cred ?? ROOT;
@@ -11381,8 +11399,10 @@ var ProcTree = class {
11381
11399
  content: () => systemFile(top, this.listing(), Date.now(), this.memory)
11382
11400
  };
11383
11401
  }
11384
- if (!/^[1-9]\d*$/.test(top) || rest2.length > 0 || !this.alive(Number(top))) return void 0;
11385
- if (leaf === void 0) return { kind: "dir", names: () => [...PID_NAMES] };
11402
+ if (!/^[1-9]\d*$/.test(top) || !this.alive(Number(top))) return void 0;
11403
+ if (leaf === "task") return this.task(Number(top), rest2);
11404
+ if (rest2.length > 0) return void 0;
11405
+ if (leaf === void 0) return { kind: "dir", names: () => [...PID_NAMES, "task"] };
11386
11406
  if (!PID_NAMES.includes(leaf)) return void 0;
11387
11407
  return {
11388
11408
  kind: "file",
@@ -11394,6 +11414,28 @@ var ProcTree = class {
11394
11414
  }
11395
11415
  };
11396
11416
  }
11417
+ info(pid) {
11418
+ return this.listing().processes.find((p) => p.pid === pid);
11419
+ }
11420
+ task(pid, rest2) {
11421
+ const [tid, leaf, ...more] = rest2;
11422
+ const tids = () => taskIds(this.info(pid));
11423
+ if (tid === void 0) return { kind: "dir", names: () => tids().map(String) };
11424
+ if (!/^[1-9]\d*$/.test(tid) || more.length > 0 || !tids().includes(Number(tid)))
11425
+ return void 0;
11426
+ if (leaf === void 0) return { kind: "dir", names: () => ["stat"] };
11427
+ if (leaf !== "stat") return void 0;
11428
+ return {
11429
+ kind: "file",
11430
+ content: () => {
11431
+ const listing = this.listing();
11432
+ const info = listing.processes.find((p) => p.pid === pid);
11433
+ const line = info && taskStat(info, Number(tid), listing.boot);
11434
+ if (line === void 0) throw syncError("ENOENT", `/proc/${pid}/task/${tid}/stat`);
11435
+ return line;
11436
+ }
11437
+ };
11438
+ }
11397
11439
  parts(path, follow2) {
11398
11440
  const parts2 = path.split("/").filter((p) => p !== "").slice(1);
11399
11441
  if (parts2[0] === "self" && (follow2 || parts2.length > 1)) parts2[0] = String(this.pid);
@@ -17045,8 +17087,14 @@ function spawnWasmProcess(opts) {
17045
17087
  umask: () => process2.umask,
17046
17088
  cred: () => copyCred(process2.cred),
17047
17089
  writesBack: () => opts.program.abi === "wasi" && !done4,
17090
+ ...clockViews(clocks)
17091
+ };
17092
+ }
17093
+ function clockViews(clocks) {
17094
+ return {
17048
17095
  times: () => clocks.times(),
17049
- running: () => clocks.running()
17096
+ running: () => clocks.running(),
17097
+ threads: () => clocks.states()
17050
17098
  };
17051
17099
  }
17052
17100
 
@@ -21568,6 +21616,7 @@ var Launcher = class {
21568
21616
  ...described2,
21569
21617
  started: (this.described.get(root.pid) ?? described2).started,
21570
21618
  state: this.stateOf(member.pid),
21619
+ ...this.threadsOf(member.pid),
21571
21620
  memory: this.processes.get(member.pid)?.memory() ?? 0,
21572
21621
  ...this.timesOf(member, members),
21573
21622
  ...this.childrenOf(root.pid),
@@ -21579,6 +21628,10 @@ var Launcher = class {
21579
21628
  }
21580
21629
  return listed;
21581
21630
  }
21631
+ threadsOf(pid) {
21632
+ const threads = this.stateOf(pid) === "S" ? this.processes.get(pid)?.threads?.() : void 0;
21633
+ return threads ? { threads } : {};
21634
+ }
21582
21635
  sudo(pid, call, signal) {
21583
21636
  const caller = {
21584
21637
  cred: this.credOf(pid),